I have following input trans.csv file:
Date,Currenncy,Symbol,Type,Units,UnitPrice,Cost,Tax
2012-03-14,USD,AAPL,BUY,1000
2012-05-12,USD,SBUX,SELL,500
The fields UnitPrice, Cost and Tax are optional. If they are not specified I expect NaN in the DataFrame cell.
I read the csv file with:
t = pandas.read_csv('trans.csv', parse_dates=True, index_col=0)
and got the following result:
Currenncy Symbol Type Units UnitPrice Cost Tax
Date
2012-03-14 USD AAPL BUY 1000 2012-05-12 012-05-12 12-05-12
2012-02-05 USD SBUX SELL 500 NaN NaN NaN
Why are there no NaN in the first row and is the Date repeated? Any workaround to get NaN for the unspecified fields?