尝试将pandas DataFrame导出到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:\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 \
我不确定为什么会收到此错误。我过去曾经多次使用熊猫写过csv。有人可以帮忙解决这个错误吗?
LastTransactionDate.to_csv(LastTransactionDate, 'example.csv')
答案 0 :(得分:2)
你的语法错了。除非我遗漏了什么,否则就这样做:
LastTransactionDate.to_csv('example.csv')