I have a dataframe like this:
df=pd.DataFrame([[1,"10/1/2019","I",2879],
[1,"10/1/2019","O",196],
[1,"10/2/2019","I",2840],
[1,"10/2/2019","O",189],
[2,"10/1/2019","I",2907],
[2,"10/1/2019","O",195]],
columns=["A","B","C","D"])
df.set_index(["A","B","C"],inplace=True)
when I display the contents they look more or less like this:
D
A B C
1 10/1/2019 I 2879
O 196
10/2/2019 I 2840
O 189
2 10/1/2019 I 2907
O 195
So my question is how to generate a csv file which contents look like it shows on the notebook where "A" and "B" values become empty on subsequent rows. In other words, this is how I need the csv file output to look like:
A,B,C,D
1,10/1/2019,I,2879
,,O,196
,10/2/2019,I,2840
,,O,189
2,10/1/2019,I,2907
,,O,195