【发布时间】:2021-08-25 10:36:02
【问题描述】:
我有一个数据框,其中包含不同的数据类型,例如有两个类 FirstGroup 和 LastGroup。
id1 id2 id3...
0 (0, FirstGroup.Other) (0, FirstGroup.Other) (0, FirstGroup.Static) ...
1 (60, LastGroups.Other) (22, LastGroups.Other) (49, LastGroups.Static) ...
所有这些对象都存储了我想以有效方式提取的数据。一个例子是:df['id1'].[0][1].name 会给我一个字符串变量'type1'。
我想要这样的东西:
id1 id2 id3...
0 (0, 'type1') (0, 'type1') (0, 'type2') ...
1 (60, 'type1') (22, 'type1') (49, 'type2') ...
我正在寻找与替换方法类似的东西,但除了循环遍历每一行和每一列之外,什么都做不了。
【问题讨论】:
标签: python-3.x pandas dataframe numpy