'module' object has no attribute 'DataFrame' [closed]

Solution 1:

The code presented here doesn't show this discrepancy, but sometimes I get stuck when invoking dataframe in all lower case.

Switching to camel-case (pd.DataFrame()) cleans up the problem.

Solution 2:

Please check if:

a) you've named a file 'pandas.py' in the same directory as your script, or

b) another variable called 'pd' is used in your program.

Solution 3:

Change the file name if your file name is like pandas.py or pd.py, as, otherwise, the file name will shadow the real name. In this case, an error message may also be raised, citing a possible circular import.

Solution 4:

For me he problem was that my script was called pandas.py in the folder pandas which obviously messed up my imports.