python - Getting a list of arrays into a Pandas dataframe -
so have list of arrays in python: [[0, 1, 0, 1], [1, 0, 1, 1], [0, 1, 1, 1]]
. make list of arrays pandas dataframe, each array being row. there way , in python? tried values = np.split(values, len(values))
split list of arrays multiple arrays (well, tried). , tried create dataframe df = pd.dataframe(values)
. error came from. got "must pass 2-d input" error message. idea i'm doing wrong , how fix it? or easier way go this? thanks!
no need splitting, etc. if have list of lists 2 dimensional (meaning rows have same number of elements), can pass dataframe
constructor:
data = [[0, 1, 0, 1], [1, 0, 1, 1], [0, 1, 1, 1]] pd.dataframe(data)
generating expected:
>>> pd.dataframe(data) 0 1 2 3 0 0 1 0 1 1 1 0 1 1 2 0 1 1 1
Comments
Post a Comment