【发布时间】:2021-08-16 22:10:11
【问题描述】:
这个问题是这里已经提出的问题的延伸:Melt multiple boolean columns in a single column in pandas
如果数据看起来像:
| System | Windows | Linux | Mac|
| -------- | -------------- |
| Desktop | True | True | False |
| Laptop | True | True | False
| Mobile | True | True | False
| Tablet | False | True | False
其中“System”为dtype=string,其他列为dtype=boolean。我怎样才能让决赛桌看起来像这样:
| OS | System |
| --- ----- | -------------- |
| Windows| Desktop Laptop Mobile |
| Linux | Desktop Laptop Mobile Tablet |
| Mac | |
System 列中的值由空格分隔。
【问题讨论】:
标签: python-3.x pandas dataframe