Python Path Issue - ayaz786amd - Nov-14-2018
There is some path issue with my python installation. Following is my code
import pandas as pd
df = pd.read_csv('ZILLOW-Z77006_ZRISFRR.csv')
print(df.head())
df.set_index('Date', inplace=True)
df.to_csv('new.csv')
df = pd.read_csv('new.csv')
print(df.head())
df = pd.read_csv('new.csv', index_col=0)
print(df.head()) AND THE ERROR IS:
Error: Traceback (most recent call last):
File "C:\Program Files\Scripts\Pandas Examples\csv.py", line 1, in <module>
import pandas as pd
File "C:\Program Files\lib\site-packages\pandas\__init__.py", line 42, in <module>
from pandas.core.api import *
File "C:\Program Files\lib\site-packages\pandas\core\api.py", line 10, in <module>
from pandas.core.groupby.groupby import Grouper
File "C:\Program Files\lib\site-packages\pandas\core\groupby\__init__.py", line 2, in <module>
from pandas.core.groupby.groupby import (
File "C:\Program Files\lib\site-packages\pandas\core\groupby\groupby.py", line 49, in <module>
from pandas.core.frame import DataFrame
File "C:\Program Files\lib\site-packages\pandas\core\frame.py", line 66, in <module>
from pandas.core.generic import NDFrame, _shared_docs
File "C:\Program Files\lib\site-packages\pandas\core\generic.py", line 48, in <module>
from pandas.io.formats.format import format_percentiles, DataFrameFormatter
File "C:\Program Files\lib\site-packages\pandas\io\formats\format.py", line 34, in <module>
from pandas.io.common import (_expand_user, _stringify_path)
File "C:\Program Files\lib\site-packages\pandas\io\common.py", line 4, in <module>
import csv
File "C:\Program Files\Scripts\Pandas Examples\csv.py", line 3, in <module>
df = pd.read_csv('ZILLOW-Z77006_ZRISFRR.csv')
AttributeError: module 'pandas' has no attribute 'read_csv'
[Finished in 1.0s with exit code 1]
[shell_cmd: python -u "C:\Program Files\Scripts\Pandas Examples\csv.py"]
[dir: C:\Program Files\Scripts\Pandas Examples]
[path: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files]
RE: Python Path Issue - buran - Nov-14-2018
Make sure that you don't have a file named pandas.py in the same folder as your file.
Also, rename your file from csv.py to something else as you shadow the built-in module with the same name csv and as you can see from the traceback pandas try to import it and in facts imports your own file and that may be the actual cause of the problem.
RE: Python Path Issue - ayaz786amd - Nov-14-2018
thanks its working fine now
|