python - Python DataFrame:Pandas groupby 行到列?
问题描述
我正在尝试将多行相同行的列
df
name subject
0 marcus math
1 marcus chemistry
2 marcus physics
3 bruno math
4 bruno physics
5 cavani math
最终df
name subject1 subject2 subject3
0 marcus math chemistry physics
1 bruno math physics
2 cavani math
Columns names can also be subject_x,subject_y,subject_z
解决方案
推荐阅读
- laravel - Laravel 5 上的表单验证
- c - 带条件格式的 Printf
- python - Pandas Dataframe 问题:应用函数添加带有结果的新列
- swift - 设置布局的理想场所
- python - 具有多个条件的 Groupby 函数
- android - I/HwPointEventFilter:不支持 AFT,因为没有配置
- flutter - 错误:“尝试创建未注册类型的平台视图:umair.mapbox_navigation/mapboxMapView”
- r - 如何检查列中的条目并在不正确时删除?
- javascript - Javascript Tic Tac Toe AI - 未选择最佳空间
- java - 改造在 API 中没有任何问题:java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $