Using groupby ("1d") and first_valid_index together
<p><a href="https://stackoverflow.com/questions/38183182/ignore-np-where-after-first-match-for-pandas-time-series-data/38183664#38183664">This</a> post shows how to use <code>first_valid_index</code> to find the first occurrence of a value in a dataframe column.  How do I use first_valid_index along with a daily groupby in order to find first occurrence each day for the same example dataframe as shown in the linked post?</p>

<p>This is the groupby code I need to use:</p>

<pre><code>grouper = pd.TimeGrouper("1d")
</code></pre>

<p>Edit:</p>

<p>When I use the <code>lambda</code> and <code>apply</code> approach it gives correct output.  I am unable to send this output to a new column <code>['test_output']</code> though as it just shows NaT:</p>

<pre><code>df['test_output'] = df.groupby(grouper)['test_1'].apply(lambda x: x.first_valid_index())

df
Out[9]:
test_1  test_output
2014-03-04 09:00:00 NaN NaT
2014-03-04 10:00:00 NaN NaT
2014-03-04 11:00:00 NaN NaT
2014-03-04 12:00:00 NaN NaT
2014-03-04 13:00:00 NaN NaT
2014-03-04 14:00:00 1.0 NaT
2014-03-04 15:00:00 1.0 NaT
2014-03-04 16:00:00 1.0 NaT
2014-03-05 09:00:00 1.0 NaT
</code></pre>