I’d like to create a pandas DataFrame from the following csv file:
...........
EUR MS 3M;20111025;7d;1.1510;
EUR MS 3M;20111024;7d;1.1530;
EUR MS 3M;20111025;1m;1.1580;
EUR MS 3M;20111024;1m;1.1590;
...........
The DataFrame ideally would have a name given as the first column value (“EUR MS 3M”), an index composed by values in the second column (“20111025”), and where the column names for the DataFrame would be taken from the third column (“7d”, “1m” etc.), with correspondent values given in the last csv column (“1.150” etc.).
I have tried with different methods, but couldn’t sort this thing out the proper way. I think the first thing I should do should be to ‘unstack’ the values in the csv, in order to have an aligned index first, and then create a DataFrame, but really don’t how…
Anyone more expert than me have any clue? I’m started learning pandas only few weeks ago…
Thanks for your kind help!
(I’m editing the question to make thing a bit clearer:
I’d like to get a dataframe named EUR MS 3M containing columns such as:
index 7d 1m
20111024 1.1530 1.1590
20111025 1.1510 1.1580
hope it is a bit clearer now. Thanks)
How about something like this: