python - Pandas data frame creation inconsistencies -


i creating pandas dataframe python dictionary:

import numpy np import pandas pd  obs_dict = {             'pos':[[0,0],[10,10]],             'vel':[[0,0],[0,0]],             'mass':np.array([10000,10000])            }  print pd.dataframe(obs_dict) 

returns:

    mass       pos     vel 0  10000    [0, 0]  [0, 0] 1  10000  [10, 10]  [0, 0] 

notice have 2d list items in position ('pos') , velocity ('vel') column. when replace 2d list 2d numpy array:

obs_dict = {             'pos':np.array([[0,0],[10,10]]),             'vel':np.array([[0,0],[0,0]]),             'mass':np.array([10000,10000])            } 

i exception:

exception: data must 1-dimensional 

unfortunately data using contained within numpy array , don't want convert python list, there way make work?

in code:

obs_dict = {         'pos':[[0,0],[10,10]],         'vel':[[0,0],[0,0]],         'mass':np.array([10000,10000])        } print pd.dataframe(obs_dict)` 

you got dataframe object columns, try dtypes:

tt = pd.dataframe(obs_dict) tt.dtypes 

shows:

mass     int64 pos     object vel     object dtype: object 

i don't think can done.


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -