When transforming multiple ndarray
to a df
as per the code below
import numpy as np
import pandas as pd
ls_a = ['TA', 'BAT', 'T']
xxx = ['xx', 'cc']
feature_no = len(ls_a)
windows_no = len(xxx)
sub_iti = np.repeat([['s1']], (feature_no * windows_no), axis=0).reshape(-1, 1)
tw = np.repeat([xxx], feature_no, axis=1).reshape(-1, 1)
col_iti = np.repeat([ls_a], windows_no, axis=0).reshape(-1, 1)
df=pd.DataFrame ({'sub_iti': sub_iti,'tw': tw,'col_iti': col_iti})
, the compiler return an error
ValueError: If using all scalar values, you must pass an index
Based on OP, the argument index
was inputed as below
df=pd.DataFrame (
{'sub_iti': sub_iti,
'tw': tw,
'col_iti': col_iti},index=range(0,3*2) )
However, the compiler return diff rent error
Exception: Data must be 1-dimensional
May I know how to address this issue?
pd.DataFrame.from_dict
? pandas.pydata.org/pandas-docs/stable/reference/api/… – swagless_monkValueError: Must pass 2-d input
– balandongiv