[Solved] 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 .dtypes it would return TypeError that Series is not callable:

enter image description here

Here it returns AttributeError.. now claiming what I read is dataframe:

enter image description here

Any thoughts?

Enquirer: dia


Solution #1:

There’s no ambiguity here. file is a dataframe, and dtypes is an attribute.

        productView  order
A               4.5    5.0
B               1.5    2.5
C               4.0    2.0
D               2.0    3.0

productView    float64
order          float64
dtype: object

When you access dtypes, a Series is returned:


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.

Respondent: cs95

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy