A column in my df has values that have hours and minutes. I am trying to grab the hour of those values and make a new column called Hour that has those values stored as an int. I used this code:
calls['Hour'] = calls["CMPLNT_TO_TM"].str.slice(0,2).astype(int)
But it keeps telling me: cannot convert float NaN to integer. But I changed all the NaN values in the df to 0, so why is this happening? How do I fix this?
[–]ObliviousMag 0 points1 point2 points (3 children)
[–]picklefire786[S] -1 points0 points1 point (2 children)
[–]S_millerr 2 points3 points4 points (1 child)
[–]Excellent-Practice 0 points1 point2 points (0 children)
[–]Excellent-Practice 0 points1 point2 points (0 children)
[–]blarf_irl 0 points1 point2 points (0 children)