虽然拆分列很容易,但是如何保留拆分列?
E.g。
a;b;c;d;e;f;g
a;b;c;d;e;f;g
a;b;c;d;e;f;g
a;b;c;d;e;f;g
现在将g分为h,i,j,k,但保持g为g(g - > h,i,j,k)
a;b;c;d;e;f;g;h;i;j;k
a;b;c;d;e;f;g;h;i;j;k
a;b;c;d;e;f;g;h;i;j;k
a;b;c;d;e;f;g;h;i;j;k
答案 0 :(得分:0)
您似乎需要split
:
df[['h','i','j','k']] = df['g'].str.split(',', expand=True)
或者:
df1 = df['g'].str.split(',', expand=True)
df1.columns = ['h','i','j','k']
df = pd.concat([df, df1], axis=1)