I have a numpy matrix and I'd like to convert it to a pandas dataframe/series. An example:
m = np.array([[1, 2], [11, 22]])
which would result in
a
0 [1, 2]
1 [11, 22]
m = np.array([[1, 2], [11, 22]])
pd.DataFrame({'col':[z for z in m]})
col
0 [1, 2]
1 [11, 22]
Or, as per @pault
pd.DataFrame({'col':list(m)})
col
0 [1, 2]
1 [11, 22]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With