我收到"[Errno 2] No such file or directory"错误代码,即使我有直接/绝对路径......有什么建议吗?



目前代码:

import pandas as pd import numpy as np
def getXDataMerged(): 
a = pd.read_csv(r'C:/Applications/AIbot1.1/usbalanceannual.csv', delimiter 
= ';') 
b = pd.read_csv(r'C:/Applications/AIbot1.1/usincomeannual.csv', delimiter = 
';') 
c = pd.read_csv(r'C:/Applications/AIbot1.1/uscashflowannual.csv', delimiter 
= ';')
print ('Income Statement CSV is: ', a.shape)
print ('Balance Sheet CSV is: ', b.shape)
print ('Cash Flow CSV is: ', c.shape)
result = pd.merge(a,b, on=['Ticker', 'SimFinId', 'Currency', 'Fiscal Year', 
'Report Date', 'Publish Date'])
result = pd.merge(result, c, on=['Ticker', 'SimFinId', 'Currency', 'Fiscal 
Year', 'Report Date', 'Publish Date'])
result["Report Date"] = pd.to_datetime(result["Report Date"])
result["Publish Date"] = pd.to_datetime(result["Publish Date"])
print('merged X data matrix shape is: ', result.shape)
return result

不太确定我的问题是什么,我的朋友有完全相同的代码(稍微不同的直接路径,因为他的文件夹在不同的地方),他没有问题....提前感谢!!

编辑:在我分享的代码下面还有一些代码,但它与我发布的内容无关。

edit2:所以我运行了一个代码,它会找到直接文件路径并打印出来给我,它说不存在这样的文件或目录作为可能的路径…为什么会这样?

我认为问题可能是因为正斜杠。你能试试用反斜杠代替吗?

a = pd.read_csv(r'C:ApplicationsAIbot1.1usbalanceannual.csv', delimiter = ';') 
b = pd.read_csv(r'C:ApplicationsAIbot1.1usincomeannual.csv', delimiter = ';') 
c = pd.read_csv(r'C:ApplicationsAIbot1.1uscashflowannual.csv', delimiter = ';')

相关内容

  • 没有找到相关文章

最新更新