Every line of 'pandas cast column to int' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
107 def _time_cols_to_ints(df, columns=None, nat_value=SMALLDT64): 108 """ 109 Converts all datetime columns to ints. 110 111 Previously NaT were convertible to ints, but now they raise a value error. 112 We need, therefore, to designate a time that will be used as NaT. 113 """ 114 cols = columns or df.select_dtypes(include=["datetime64"]).columns 115 df.loc[:, cols] = df.loc[:, cols].fillna(nat_value).astype(np.int64) 116 return df