Typeerror: 'series' Object Is Not Callable When Accessing Dtypes Of A Dataframe
What the hell? I didn't change the keyword to reading the text file I have on my directory. Yet I can't check the dtype of each columns by the two methods that I know of. If I use
Solution 1:
There's no ambiguity here. file
is a dataframe, and dtypes
is an attribute.
df
productView order
userId
A4.55.0B1.52.5
C 4.02.0
D 2.03.0
df.dtypes
productView float64
order float64
dtype: object
When you access dtypes
, a Series is returned:
type(df.dtypes)
pandas.core.series.Series
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
.
Post a Comment for "Typeerror: 'series' Object Is Not Callable When Accessing Dtypes Of A Dataframe"