擅长:python、mysql、java
<p>您可以考虑在DataFrame上使用pivot\u table方法,并使用自己的函数来做一些只有在您想要的条件为真时才有意义的事情。然后,如果没有0的数据,也应该填充标记和日期。比如:</p>
<pre><code>def calc(column):
total = 0
for e in column:
if e == 1:
total += 1
return total
check_res = df.pivot_table(index='tags',columns='date', values='ease', aggfunc=calc, fill_value=0)
</code></pre>