野球のデータを作りたいのですが、アウトカウントの列を一行前の値を利用してfor文とappendを使って一気に作りたいのですが、何が原因かわからないのですが
SyntaxError: invalid syntaxになってしまいます。
tmp_se = Series~~~~~の行がエラーになります。
python
1def single(xxx): 2 if xxx < 2 : 3 xxx += 1 4 else : 5 xxx = 0 6 return xxx 7 8def double(yyy): 9 if yyy < 1 : 10 yyy += 2 11 else : 12 yyy = 0 13 return yyy 14 15def triple(zzz): 16 if zzz == 0 : 17 zzz == 0 18 return zzz
python
1# データフレームを作る 2list_df = pd.DataFrame(columns=['アウトカウント']) 3# アウトカウントを埋める 4for idx,row in re_df.iloc[:,[4]].interrows(): 5 tmp_se = pd.Series(lambda re_df['結果']: single(re_df.shift(1).loc[idx,'アウトカウント'])'アウト' if re_df['結果'] == 'アウト' else double(re_df.shift(1).loc[idx,'アウトカウント'])'アウト' if re_df['結果'] == 'ダブルプレー' else triple(re_df.shift(1).loc[idx,'アウトカウント'])'アウト' if re_df['結果'] == 'トリプルプレー' else None, index=list_df.columns).fillna(method='ffill') 6 7 list_df = list_df.append( tmp_se, ignore_index=True ) 8 9list_df
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/09/25 09:58