dataframe 新增单列
assign方法
dataframe assign方法,返回一个新对象(副本),不影响旧dataframe对象
import pandas as pd
df...= pd.DataFrame({
'col_1': [0, 1, 2, 3],
'col_2': [4, 5, 6, 7]
})
sLength = len...新增列
import pandas as pd
df = pd.DataFrame({
'col_1': [0, 1, 2, 3],
'col_2':...新增多列
list unpacking
import pandas as pd
import numpy as np
df = pd.DataFrame({...也可以一行匹配
df[['column_new_1', 'column_new_2', 'column_new_3']] = pd.DataFrame([[np.nan, 'dogs', 3]], index