擅长:python、mysql、java
<p>假设您想要<code>groupby</code>日期和小时,如果timestamp列是datetime列,则可以使用以下代码</p>
<pre><code>df.year = df.timestamp.dt.year
df.month = df.timestamp.dt.month
df.day = df.timestamp.dt.day
df.hour = df.timestamp.dt.hour
grouped_data = df.groupby(['year','month','day','hour','category']).count()
</code></pre>