df_preds['0']において、欠損値がある行番号とない行番号を抽出します。
dfの、df_preds['0']における欠損値がない行番号の行全てをdf_x_trainに繋げていきます。
dfの、df_preds['0']における欠損値がある行番号の行全てをdf_x_testに繋げていきます。
df_predsの、df_preds['0']における欠損値がない行番号の行全てをdf_t_trainに繋げていきます。
上記を実装したところ、エラーが発生しました。
どなたか、解決方法を教えて頂けると幸いです。
python
1df_x_test = df_preds 2df_x_train = df_preds 3df_t_train = df_preds['0'] 4 5for i, j in enumerate(df_preds['0'].isnull()): 6 if j == True: 7 df_x_test = pd.concat(df_x_test, df.loc[i, :]) 8 else: 9 df_x_train = pd.concat(df_x_train, df.loc[i, :]) 10 df_t_train = pd.concat(df_t_train, df_preds.loc[i, '0']) 11
error
1--------------------------------------------------------------------------- 2TypeError Traceback (most recent call last) 3<ipython-input-12-58893862488f> in <module> 4 7 df_x_test = pd.concat(df_x_test, df.loc[i, :]) 5 8 else: 6----> 9 df_x_train = pd.concat(df_x_train, df.loc[i, :]) 7 10 df_t_train = pd.concat(df_t_train, df_preds.loc[i, '0]) 8 11 9 10c:\users\t16cs039\appdata\local\programs\python\python37-32\lib\site-packages\pandas\core\reshape\concat.py in concat(objs, axis, join, join_axes, ignore_index, keys, levels, names, verify_integrity, sort, copy) 11 226 keys=keys, levels=levels, names=names, 12 227 verify_integrity=verify_integrity, 13--> 228 copy=copy, sort=sort) 14 229 return op.get_result() 15 230 16 17c:\users\t16cs039\appdata\local\programs\python\python37-32\lib\site-packages\pandas\core\reshape\concat.py in __init__(self, objs, axis, join, join_axes, keys, levels, names, ignore_index, verify_integrity, copy, sort) 18 242 raise TypeError('first argument must be an iterable of pandas ' 19 243 'objects, you passed an object of type ' 20--> 244 '"{name}"'.format(name=type(objs).__name__)) 21 245 22 246 if join == 'outer': 23 24TypeError: first argument must be an iterable of pandas objects, you passed an object of type "DataFrame"
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。