我有一个Pd数据框架,在不同的日期有“看涨”和“看跌”的情绪。我在一个新的专栏中统计了情绪的数量。现在我想创建两个新的列,一个是“看涨”的,另一个是“看跌的”,这样它就可以计算在这样的日期里出现了多少情绪。Now the output looks like this. As you can see, there may have both 'Bullish' and 'Bearish' on the same date. And it is hard to do analysis in this form. I want to create two new columns to separate the 'Bullish' and 'Bearish'
例如,对于日期08/01/2014,我的预期结果是在同一行的新列‘看涨’中有一个数字8,在新列‘看跌’中有一个数字1。
对此有什么想法吗?谢谢!
发布于 2019-07-25 22:16:50
您可以简单地在索引中拆分'sentN‘级别:
df.unstack('sentN')我希望它能帮上忙!
https://stackoverflow.com/questions/57203179
复制相似问题