我有一个dataframe
如下所示:
In [74]: data2
Out[74]:
a b c
2012-06-12 0 1 1
2012-06-13 1 1 0
2012-06-14 1 0 1
2012-06-15 1 0 1
2012-06-16 1 1 0
2012-06-17 1 0 1
有没有办法让值 = 值 = 1 的列标题?
结果df:
a b c
2012-06-12 0 b c
2012-06-13 a b 0
2012-06-14 a 0 c
2012-06-15 a 0 c
2012-06-16 a b 0
2012-06-17 a 0 c
然后删除 = 0 的值,使 df 减少到 2 列:(此时列标题不相关)
结果df:
1 2
2012-06-12 c b
2012-06-13 a b
2012-06-14 a c
2012-06-15 a c
2012-06-16 a b
2012-06-17 a c