![](/img/trans.png)
[英]Pandas - How to ignore percentages in read_excel and read_csv
[英]read_excel or read_csv on pandas
我尝试了熊猫方法,但它不起作用。 我的文件名为“Classeur1”。 我无法在 Jupyter 或 Spyder 上加载它。
import pandas as pd
df = pd.read_csv("TP 2 FIN 3500.xlsx")
df.head()
我得到:
File "<ipython-input-1-2b6f31d9e40c>", line 1, in <module>
runfile('C:/Users/alber/.spyder-py3/temp.py', wdir='C:/Users/alber/.spyder-py3')
File "C:\Users\alber\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "C:\Users\alber\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/alber/.spyder-py3/temp.py", line 2, in <module>
df = pd.read_csv("TP 2 FIN 3500.xlsx")
File "C:\Users\alber\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 685, in parser_f
return _read(filepath_or_buffer, kwds)
File "C:\Users\alber\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 457, in _read
parser = TextFileReader(fp_or_buf, **kwds)
File "C:\Users\alber\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 895, in __init__
self._make_engine(self.engine)
File "C:\Users\alber\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 1135, in _make_engine
self._engine = CParserWrapper(self.f, **self.options)
File "C:\Users\alber\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 1917, in __init__
self._reader = parsers.TextReader(src, **kwds)
File "pandas\_libs\parsers.pyx", line 382, in pandas._libs.parsers.TextReader.__cinit__
File "pandas\_libs\parsers.pyx", line 689, in pandas._libs.parsers.TextReader._setup_parser_source
FileNotFoundError: [Errno 2] File b'TP 2 FIN 3500.xlsx' does not exist: b'TP 2 FIN 3500.xlsx'
I also tried both method with the absolute: C:\Users\alber\Documents\Downloads\python stockage
无法使用 Pandas 数据框加载文件
谢谢 !
阅读excel试试这个。
df = pd.read_excel("TP 2 FIN 3500.xlsx")
如果 Classeur1 是 CSV 文件,那么试试这个。
df = pd.read_excel("Classeur1.csv")
另外,检查文件是否与笔记本放在同一目录中,以便找到它。
你读取excel文件如下:
df = pd.read_excel (r'Path where the Excel file is stored\File name.xlsx')
如果您使用 pd.read_csv() 则将您的 excel 文件转换为 .CSV 格式。 Aslo 将您的 excel 或 .csv 文件放在此目录中:C:\\Users\\alber。
df= pd.read_csv("your_filename.csv")
您还可以通过使用以下代码更改 jupyter 运行目录路径来使用另一种方法:-
os.chdir('D:\folder_path_of_csv_file')
print(os.getcwd())
df= pd.read_csv("your_filename.csv")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.