I have a dataframe df
like this:
date1 date2 A
2015.1.1 2015.1.2 1
2015.1.1 2015.1.3 2
2015.1.1 2015.1.4 3
2015.1.2 2015.1.3 4
2015.1.2 2015.1.4 5
2015.1.3 2015.1.4 6
<class 'pandas.core.frame.DataFrame'>
Int64Index: 1711 entries, 0 to 1710
Data columns (total 3 columns):
date1 1711 non-null datetime64[ns]
date2 1711 non-null datetime64[ns]
A 1711 non-null float64
dtypes: datetime64[ns](2), float64(1)
memory usage: 53.5 KB
How to convert df
to a matrix mx
like this:
2015.1.2 2015.1.3 2015.1.4
2015.1.1 1 2 3
2015.1.2 - 4 5
2015.1.3 - - 6
Then, I need to export mx
to the Excel or csv file.