我有福勒。数据帧:
a_name Season yl
yl
4.939 cherka 2000.0 [4.939]
4.441 cherka 2001.0 [4.441]
4.320 cherka 2002.0 [4.32]
3.718 cherka 2003.0 [3.718]
4.533 cherka 2004.0 [4.533]
如何将其转换为:
a_name Season yl
yl
4.939 cherka 2000.0 4.939
4.441 cherka 2001.0 4.441
4.320 cherka 2002.0 4.32
3.718 cherka 2003.0 3.718
4.533 cherka 2004.0 4.533
我是这样做的:
df.groupby(['a_name', 'Season', 'yl'])['yl'].unique().reset_index(level=[0,1])
数据输入
使用numpy:
df["y1"] = np.vstack(df["y1"])
扩展我的评论,使用
.str[0]
:您可以选择使用
assign
(piRsquared's suggestion)创建副本:相关问题 更多 >
编程相关推荐