Python Pandas Group by date using datetime data
<p>I have a column <code>Date_Time</code> that I wish to groupby date time without creating a new column. Is this possible the current code I have does not work.</p>

<pre><code>df = pd.groupby(df,by=[df['Date_Time'].date()])
</code></pre>

<p>You can use <code>groupby</code> by dates of column <code>Date_Time</code> by <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.dt.date.html" rel="nofollow"><code>dt.date</code></a>:</p>

<pre><code>df = df.groupby([df['Date_Time'].dt.date]).mean()
</code></pre>

<p>Sample:</p>

<pre><code>df = pd.DataFrame({'Date_Time': pd.date_range('10/1/2001 10:00:00', periods=3, freq='10H'),
                   'B':[4,5,6]})

print (df)
   B           Date_Time
0  4 2001-10-01 10:00:00
1  5 2001-10-01 20:00:00
2  6 2001-10-02 06:00:00

print (df['Date_Time'].dt.date)
0    2001-10-01
1    2001-10-01
2    2001-10-02
Name: Date_Time, dtype: object

df = df.groupby([df['Date_Time'].dt.date])['B'].mean()
print(df)
Date_Time
2001-10-01    4.5
2001-10-02    6.0
Name: B, dtype: float64
</code></pre>

<p>Another solution  with <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.resample.html" rel="nofollow"><code>resample</code></a>:</p>

<pre><code>df = df.set_index('Date_Time').resample('D')['B'].mean()

print(df)
Date_Time
2001-10-01    4.5
2001-10-02    6.0
Freq: D, Name: B, dtype: float64
</code></pre>

python date datetime pandas group-by