I have an exported Excel CSV file with str(date), str, float, float, float, float, int as column values. Some of the Excel cells are empty, thus using keep_default_na is needed.
Some are in double quotes, thousand separators present.
The number of parameters seems to confuse the pandas parser because running this outputs:
ValueError: could not convert string to float: '1,917.6'
Seems that when keep_default_na is present, thousands gets ignored. When I run this without any ,,,,,, lines in the csv, it works perfectly.
CSV FILE:
TS
Date,Symbol,Open,High,Low,Close,Volume
6/14/2022 23:59,A,918.1,918.1,918.1,918.1,1
,,,,,,
6/14/2022 23:57,A,"1,917.6",917.6,917.6,917.6,1
,,,,,,
,,,,,,
CODE
df = pd.read_csv('test.csv',
skiprows=1,
quotechar='"',
thousands=',',
keep_default_na=False,
dtype = {'Open': np.float64, 'High': np.float64,
'Low': np.float64, 'Close': np.float64,
'Volume': np.uint32, 'Symbol': 'string'})