Python:将数据帧导出到CSV文件时出错
尝试将pandas数据帧导出到csv时出现以下错误Python:将数据帧导出到CSV文件时出错,python,csv,pandas,export,writing,Python,Csv,Pandas,Export,Writing,尝试将pandas数据帧导出到csv时出现以下错误 Traceback (most recent call last): File "C:/Users/riley/PycharmProjects/EarlyPaidLoanReport/EarlyPaidOff.py", line 91, in <module> LastTransactionDate.to_csv(LastTransactionDate, 'example.csv') File "C:
Traceback (most recent call last):
File "C:/Users/riley/PycharmProjects/EarlyPaidLoanReport/EarlyPaidOff.py", line 91, in <module>
LastTransactionDate.to_csv(LastTransactionDate, 'example.csv')
File "C:\Users\riley\Anaconda3\lib\site-packages\pandas\core\frame.py", line 1344, in to_csv
formatter.save()
File "C:\Users\riley\Anaconda3\lib\site-packages\pandas\formats\format.py", line 1526, in save
compression=self.compression)
File "C:\Users\riley\Anaconda3\lib\site-packages\pandas\io\common.py", line 424, in _get_handle
f = open(path, mode, errors='replace')
TypeError: invalid file: AutoNumber LoanAgreementID \
你的语法错了。除非我遗漏了什么,否则就这么做:
LastTransactionDate.to_csv('example.csv')
参数则相反。首先是文件名…LastTransactionDate.to_csv('example.csv')
。为什么要复制您的DF
?
LastTransactionDate.to_csv(LastTransactionDate, 'example.csv')