I'm trying to use pandas DataFrame in PyCharm. When I try typing DataFrame - as per the screenshot below - DataFrame doesn't show up. When I manually type it, it show up like that. Finally, when I try to run the script it brings up this error: AttributeError: module 'pandas' has no attribute 'DataFrame'. (the script file is just for demonstration). Pandas installed version is 2.0.2, PyCharm version 2023.1.2
Asked
Active
Viewed 99 times
0
-
1What it the output of `print(pd.__version__)` or `print(type(pd))`? – Corralien Jun 01 '23 at 22:18
-
2What is the output of `print(pd)`? You probably accidentally created a module named `pandas` that's shadowing the actual pandas module. – wjandrea Jun 01 '23 at 22:28
-
Please always post the [full error message with traceback](https://meta.stackoverflow.com/q/359146/4518341) – wjandrea Jun 01 '23 at 22:39
-
Possible duplicate: [Importing a library from (or near) a script with the same name raises "AttributeError: module has no attribute" or an ImportError or NameError](/q/36250353/4518341) – wjandrea Jun 01 '23 at 22:41
-
@Corralien `print(type(pd))` is always going to be `
`. Maybe you meant `print(pd)`? – wjandrea Jun 01 '23 at 22:44 -
@wjandrea. Yes if `pd` is a module. I didn't want to see the full path of the module but you are right if the module is "shadowed" it's important to see the path of the module! Good point. – Corralien Jun 02 '23 at 07:16
-
I did run print(pd) and here is the output:
Process finished with exit code 0 – Moh Jun 02 '23 at 08:50 -
@Corralien What would it be besides a module? – wjandrea Jun 02 '23 at 14:44
-
A variable. Like `pd = ...` but the screenshot shows it can't be that. – Corralien Jun 02 '23 at 16:14