AttributeError: module 'mypandas' has no attribute 'print_pandas_df'
<p>I have the following python program <code>test_pandas.py</code>.</p>

<pre><code># !/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))
</code></pre>

<p>My folder structure is as follows.</p>

<pre><code>--python
  --concepts
    --mypandas
      --mypandas.py
      --__init__.py
    --test_pandas.py
</code></pre>

<p>When I run the <code>test_pandas.py</code> I get the following error.</p>

<pre><code>  UserWarning)
Traceback (most recent call last):
  File "C:/Cubic/playpen/python/concepts/pandas/test_pandas.py", line 11, in &lt;module&gt;
    mypandas.print_pandas_df(df,50,8)
AttributeError: module 'mypandas' has no attribute 'print_pandas_df'
</code></pre>

<p><code>mypandas.py</code> has the function <code>print_pandas_df</code></p>

<pre><code>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)
</code></pre>

<p>You need to put the full path: directory.filename.methodname:</p>

<pre><code>mypandas.mypandas.print_pandas_df(df,50,8)
</code></pre>

<p>You can also say</p>

<pre><code>from mypandas import mypandas
</code></pre>

<p>and then write your code as is.</p>

python pandas