let’s say I have a data like:
parameter1 parameter2 2010 2011 2012
A B foo foo foo
C foo foo foo
D foo foo foo
M N bar bar bar
O bar bar bar
which exported to CSV would look something like this:
parameter1,parameter2,2010,2011,2012
A,B,foo,foo,foo
,C,foo,foo,foo
,D,foo,foo,foo
M,N,bar,bar,bar
,O,bar,bar,bar
when I try to read the csv like:
pd.read_csv("file.csv", index_col=[0,1])
I however get:
2010 2011 2012
A B foo foo foo
NaN C foo foo foo
D foo foo foo
M N bar bar bar
NaN O bar bar bar
Is there a way to make Pandas understand that if the value haven’t been provided for a row Index as CSV it should treat it like the indexed hasn’t changed, instead of giving it NaN index?
What I would expect instead after reading csv:
2010 2011 2012
A B foo foo foo
C foo foo foo
D foo foo foo
M N bar bar bar
O bar bar bar