【发布时间】:2020-12-02 07:38:17
【问题描述】:
我收到语法错误,我不知道为什么。你能帮帮我吗? 我正在尝试读取多个 .csv 文件。
import pandas as pd
from glob import glob
gas_prices= sorted(glob('Gas prices/2020****_EEXGasFutures_SettlementPrices.csv'))
gas_prices
pd.concat((pd.read_csv(file).assign(filename = file)
for file in gas prices), ignore_index = True)
错误信息:
File "<ipython-input-17-cacfa11dbcf0>", line 2
for file in gas prices), ignore_index = True)
^
SyntaxError: invalid syntax
【问题讨论】:
-
将
for file in gas prices更改为for file in gas_prices并带有下划线 -
错误说明很清楚,gas 价格是错误的。使用 gas_prices
标签: python pandas syntax-error