-1

installed pandas package successfully. Import the pandas. Getting below error while run the sample code.

code:

import pandas as pd

df1 = pd.DataFrame({"A": ["A0", "A1", "A2", "A3", "A4"]}, index=[0])
print(df1)

error:

Traceback (most recent call last):
  File "D:/Users/prabhakar_d/Box/S&P Local_mine/PycharmProjects/practise_project/sample/default_keywr_parm.py", line 11, in <module>
    import pandas as pd
  File "C:\Program Files\Python36\lib\site-packages\pandas\__init__.py", line 22, in <module>
    from pandas.compat.numpy import (
  File "C:\Program Files\Python36\lib\site-packages\pandas\compat\numpy\__init__.py", line 9, in <module>
    _np_version = np.__version__
AttributeError: module 'numpy' has no attribute '__version__'
1

3 Answers 3

0

See you are passing 5 rows and 1 column(5,1) but the index parameter is saying that it is 1 row and 1 column (1,1) so try removing the index parameter.

Sign up to request clarification or add additional context in comments.

Comments

0

First step check your numpy version I don't know how does it bug in your numpy, But now I already try your script

import pandas as pd

df1 = pd.DataFrame({"A": ["A0", "A1", "A2", "A3", "A4"]}, index=[0])
print(df1)

And I don't met like your error on my numpy(1.19.4)

enter image description here

So please try to update your numpy. And then follow to the First answer from: @Vibhav_Surve

when you try to run your code with your script. If you still run with add index() you will found this error like this. enter image description here

Comments

0

try removing index from your df1 varable...

import pandas as pd
df1 = pd.DataFrame({"A":["A0","A1","A2","A3","A4"]})
print(df1)

o/p

    A
0  A0
1  A1
2  A2
3  A3
4  A4

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.