Python Forum

Full Version: help on pandas circular import
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi

i try to test this basic code but i have the message AttributeError: partially initialized module 'pandas' has no attribute 'Series' (most likely due to a circular import)
import pandas as pd

a = [1, 7, 2]

myvar = pd.Series(a)

print(myvar)
what is wrong please??
See if you have name i file pandas.py then rename of delete it.
import pandas as pd

a = [1, 7, 2]
myvar = pd.Series(a)
print(myvar)
Output:
0 1 1 7 2 2 dtype: int64
See that pandas has a placement in site-packages folder.
>>> import pandas
>>> 
>>> pandas.Series
<class 'pandas.core.series.Series'>
>>> pandas.__file__
'C:\\Python39\\lib\\site-packages\\pandas\\__init__.py'
(May-18-2021, 11:50 AM)snippsat Wrote: [ -> ]See if you have name i file pandas.py then rename of delete it.
import pandas as pd

a = [1, 7, 2]
myvar = pd.Series(a)
print(myvar)
Output:
0 1 1 7 2 2 dtype: int64
See that pandas has a placement in site-packages folder.
>>> import pandas
>>> 
>>> pandas.Series
<class 'pandas.core.series.Series'>
>>> pandas.__file__
'C:\\Python39\\lib\\site-packages\\pandas\\__init__.py'

correct, thanks!