Column Assignment Methods¶
CAM-1: Direct assignment¶
df["c"] = [7, 8, 9]
Supported
CAM-2: Attribute assignment¶
df.col = value
Not Supported
CAM-3: loc indexer¶
df.loc[:, 'col'] = value
Not Supported
CAM-4: iloc indexer¶
df.iloc[:, index] = value
Not Supported
CAM-5: at indexer¶
df.at[row, 'col'] = value
Not Supported
CAM-6: iat indexer¶
df.iat[row, col_idx] = value
Not Supported
CAM-7: assign method¶
df = df.assign(A=[1, 2, 3])
Tested but not supported
CAM-8: Multiple assign¶
df = df.assign(B=1, C=2)
Not Supported
CAM-9: insert method¶
df.insert(0, "A", [1, 2, 3])
Supported
CAM-10: setitem with list¶
df[["c", "d"]] = [[7, 8, 9], [10, 11, 12]]
Supported
CAM-11: From dictionary¶
df = pd.DataFrame({'A': [1,2], 'B': [3,4]})
Not Supported
CAM-12: concat¶
df = pd.concat([df, new_df], axis=1)
Not Supported
CAM-13: join¶
df = df.join(other_df)
Not Supported
CAM-14: merge¶
df = df.merge(df2, on='key')
Not Supported
CAM-15: From eval¶
df.eval('C = A * 2', inplace=True)
Not Supported
CAM-16: From query results¶
df['new'] = df.query('A > 0')['B']
Not Supported
CAM-17: Conditional assignment¶
df.loc[df['A'] > 0, 'B'] = 1
Not Supported
CAM-18: Copy from another column¶
df['B'] = df['A'].copy()
Not Supported
CAM-19: Transform operations¶
df['B'] = df['A'].apply(lambda x: x*2)
Not Supported
CAM-20: Expanding columns¶
df[['A','B']] = df['combined'].str.split(expand=True)
Not Supported
CAM-21: From groupby¶
df['new'] = df.groupby('A')['B'].transform('mean')
Not Supported
CAM-22: From pivot¶
df.pivot(columns='A')
Not Supported
CAM-23: From unstack¶
df = df.unstack()
Not Supported
CAM-24: From pd.get_dummies¶
df = pd.get_dummies(df, columns=['A'])
Not Supported
CAM-25: Update method¶
df.update(other_df[['A']])
Not Supported