python pandas 'AttributeError: Can only use .dt accessor with datetimelike values' decimal to hours
<p>I have a column in a df that looks like </p>

<pre><code>hour
1.0
2.0
3.0
6.0 
Nan
</code></pre>

<p>I want to convert this into a time format so like below</p>

<pre><code>hour
1:00
2:00
3:00
6:00
</code></pre>

<p>However I cannot get the formatting correct. I have tried to coerce the format like below. I would also like the logic to leave the Nan values.</p>

<pre><code>pd.to_datetime(df['hour'], format='%H', coerce=True)
</code></pre>

<p>But this only returns NaT values.</p>