module 'pandas' has no attribute 'Dataframe'

0 views
Skip to first unread message

Aastha

unread,
Nov 23, 2015, 1:04:18 AM11/23/15
to Anaconda - Public
Hi,

I am trying to compare to compare three columns max, min , exp_year in my csv file. I am using dataframe for this and trying to to check if min<=exp_year<= max, a new column should be added with corresponding value true else false. But m getting following error : 
 module 'pandas' has no attribute 'Dataframe'

Below is my code :

from pandas import DataFrame, read_csv
import matplotlib.pyplot as plt
import pandas as pd

%matplotlib inline
df = pd.read_csv("C:\\Users\\ssl\\Desktop\\train.csv", header=None)
df = pd.read_csv("C:\\Users\\ssl\\Desktop\\train.csv",names=['min','max','exp_year','exp_month','ratio'],header=None)
#pd.read_csv(StringIO(data), usecols=['min', 'exp_year','max'])
print(df)

df['f1']=pd.Dataframe(df['min'] <= df['exp_year'] and df['exp_year'] <= df['max']).bool()

data is like this:
    min  max  exp_year  exp_month  ratio
0     7   11         6          3   0.25
1     2    6         6          3   0.25
2     2    7         6          3   0.25
3     3    4         6          3   0.25
4     2    7         6          3   0.25
5     2    4         6          3   0.25
6     3    5         6          3   0.25
7     3    5         6          3   0.25
8     2    5         6          3   0.25
9     2   10         6          3   0.25
10    2    3         6          3   0.25
11    2    5         6          3   0.25
12    3    5         6          3   0.25
13    1    2         6          3   0.25
14    1    9         6          3   0.25
15    1    4         6          3   0.25
16    1    8         6          3   0.25
17    2    4         6          3   0.25
18    3   10         6          3   0.25
19    3    7         6          3   0.25
20    4    8         6          3   0.25
21    4   10         6          3   0.25
22    4    8         6          3   0.25
23    3    5         6          3   0.25
24    3    5         6          3   0.25
25    4    6         6          3   0.25
26    3   10         6          3   0.25
27    1    7         6          3   0.25
28    1    7         6          3   0.25
29    2    8         6          3   0.25

Eric Firing

unread,
Nov 23, 2015, 1:19:07 AM11/23/15
to anac...@continuum.io
On 2015/11/22 8:04 PM, Aastha wrote:
> Hi,
>
> I am trying to compare to compare three columns max, min , exp_year in
> my csv file. I am using dataframe for this and trying to to check if
> min<=exp_year<= max, a new column should be added with corresponding
> value true else false. But m getting following error :
>
> module 'pandas' has no attribute 'Dataframe'

It's case-sensitive: DataFrame.

>
>
> Below is my code :
>
> from pandas import DataFrame, read_csv
> import matplotlib.pyplot as plt
> import pandas as pd
>
> %matplotlib inline
> df = pd.read_csv("C:\\Users\\ssl\\Desktop\\train.csv", header=None)
> df =
> pd.read_csv("C:\\Users\\ssl\\Desktop\\train.csv",names=['min','max','exp_year','exp_month','ratio'],header=None)
> #pd.read_csv(StringIO(data), usecols=['min', 'exp_year','max'])
> print(df)
>

The line below is the problem.
> df['f1']=pd.Dataframe(df['min'] <= df['exp_year'] and df['exp_year'] <=

Eric

Aastha

unread,
Nov 23, 2015, 1:26:52 AM11/23/15
to Anaconda - Public
Thanks Eric,

Can you suggest me the proper code for that line ?

Eric Firing

unread,
Nov 23, 2015, 1:09:04 PM11/23/15
to anac...@continuum.io
On 2015/11/22 8:26 PM, Aastha wrote:
> Thanks Eric,
>
> Can you suggest me the proper code for that line ?
>
Just change "Dataframe" to "DataFrame". Note the capital "F".

maso...@gmail.com

unread,
Dec 1, 2016, 2:54:43 PM12/1/16
to Anaconda - Public
God bless you!

Paul Kiragu

unread,
Jan 26, 2020, 2:06:43 PM1/26/20
to Anaconda - Public, aas...@iimjobs.com
I had a slightly similar problem, just incase anyone has the same issue, note that invoking dataframe should be done using camelcase. eg define_frame = pd.DataFrame(myDictionary)
print(define_frame)

vivek jha

unread,
May 9, 2020, 8:05:03 AM5/9/20
to Anaconda - Public
Thanks Eric...In my case it was the Big F...LOL

pradyum soni

unread,
May 15, 2020, 1:31:22 PM5/15/20
to Anaconda - Public, aas...@iimjobs.com
Thanks a lot !! Been struggling for 2-3 hours


On Monday, November 23, 2015 at 11:34:18 AM UTC+5:30, Aastha wrote:

Squink III

unread,
May 15, 2020, 1:48:49 PM5/15/20
to anac...@continuum.io, aas...@iimjobs.com
I don't see exactly why your code shouldn't work, but I would either drop the line

from pandas import DataFrame, read_csv

Or stop referring to those methods through the pd object.  That redundancy could lead to problems.

I recommend breaking down the assignment df['f1'] = into smaller operations to help determine exactly where the error occurs.  Although I don't claim to be a subject matter expert, I've noticed a lot of what seems to be underlying typecasting problems in this weakly-typed language that has been the source of considerable frustration.

Warm regards,
Sean

Warm regards,

S


From: anac...@continuum.io <anac...@continuum.io> on behalf of pradyum soni <pradyum...@gmail.com>
Sent: Friday, May 15, 2020 11:31:21 AM
To: Anaconda - Public <anac...@continuum.io>
Cc: aas...@iimjobs.com <aas...@iimjobs.com>
Subject: [Anaconda Community] Re: module 'pandas' has no attribute 'Dataframe'
 
--
Community Discussion Forum for Anaconda
---
You received this message because you are subscribed to the Google Groups "Anaconda - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to anaconda+u...@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/anaconda/52b0a529-bd42-47d8-bb35-1858d95054b4%40continuum.io.
Reply all
Reply to author
Forward
0 new messages