python - How to convert matrix to pandas data frame -



python - How to convert matrix to pandas data frame -

i'm trying convert matrix pandas info frame:

matrixa={} matrixa[0,0]='a' matrixa[0,1]='b' matrixa[1,0]='c' matrixa[1,1]='d'

like this:

import pandas pd pd.dataframe(matrixa)

i error.

as said not creating matrix python dictionary. dict can serve parameter create dataframe, reversed indexing order.

import pandas pd matrixa={} matrixa['a']=[0,0] matrixa['b']=[0,1] pd.dataframe(matrixa) b 0 0 0 1 0 1

additionally can utilize numpys matrix

import numpy np = np.matrix('1 2; 3 4') pd.dataframe(a) 0 1 0 1 2 1 3 4

python pandas

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -