As it is [Duplicate], I have raised this to be removed. Kindly do not rollback.
Advertisement
Answer
There’s no ambiguity here. file
is a dataframe, and dtypes
is an attribute.
JavaScript
x
13
13
1
df
2
productView order
3
userId
4
A 4.5 5.0
5
B 1.5 2.5
6
C 4.0 2.0
7
D 2.0 3.0
8
9
df.dtypes
10
productView float64
11
order float64
12
dtype: object
13
When you access dtypes
, a Series is returned:
JavaScript
1
3
1
type(df.dtypes)
2
pandas.core.series.Series
3
When you call df.dtypes()
, you are effectively doing series = df.dtype; series()
which is invalid, since series
is an object (not a function, or an object with __call__
defined).
In the second case, dtype
isn’t even a valid attribute/method of df
, and so an AttributeError
is raised.
TLDR; The first error is raised on the dtype
series, the second is raised on the original dataframe df
.