I have the following python program test_pandas.py.
# !/usr/bin/env python3.4
# -*- coding: utf-8 -*-
import pprint
import pandas as pd
import mypandas.mypandas
df = pd.read_csv('AllStarFull.csv')
mypandas.print_pandas_df(df,50,8)
# groupby 'player ID'
print('Grouping by Player ID')
gb = df.groupby(['playerID'])
pprint.pprint(list(gb))
# groupby 'yearID'
print('Grouping by Year ID')
gb = df.groupby(['yearID'])
pprint.pprint(list(gb))
My folder structure is as follows.
--python
--concepts
--mypandas
--mypandas.py
--__init__.py
--test_pandas.py
When I run the test_pandas.py I get the following error.
UserWarning)
Traceback (most recent call last):
File "C:/Cubic/playpen/python/concepts/pandas/test_pandas.py", line 11, in <module>
mypandas.print_pandas_df(df,50,8)
AttributeError: module 'mypandas' has no attribute 'print_pandas_df'
mypandas.py has the function print_pandas_df
import pandas as pd
import pprint
def print_pandas_df(df, rows, columns):
with pd.option_context('display.max_rows', rows, 'display.max_columns', columns):
pprint.pprint(df)