0

I am getting a syntax error and I don`t know why. Can you please help me out? I am trying to read in multiple .csv files.

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)

Error message:

File "<ipython-input-17-cacfa11dbcf0>", line 2
    for file in gas prices), ignore_index = True)
                         ^
SyntaxError: invalid syntax
linamnt
  • 1,315
  • 1
  • 12
  • 23
Endre
  • 49
  • 1
  • 7

1 Answers1

0

You made a syntactical error, in pd.concat() gas prices should be gas_prices:

import pandas as pd
from glob import glob

gas_prices= sorted(glob('Gas prices/2020****_EEXGasFutures_SettlementPrices.csv'))

pd.concat((pd.read_csv(file).assign(filename = file)
           for file in gas_prices), ignore_index = True)
Marios
  • 26,333
  • 8
  • 32
  • 52