Change UInt32 to int64 for dt.isocalendar().week calculations
try .astype(numpy.int64) or .astype("int64")
For a data science project I used to calculate the week numbers through this code:
df['Week_Nr'] = df['Date'].dt.week
As this function is now depreciated I changed to
df['Week_Nr'] = df['Date'].dt.isocalendar().week
Yet my output used to be in int64 and now is in UInt32
And this is causing an error in a following calculation: "ValueError: DataFrame.dtypes for data must be int, float or bool.Did not expect the data types in fields Week_Nr"
So my question is how I can modify the isocalendar().week to give me a int64 output or how to transform the column to int64 as I have not been successful in finding the right code.
This code did not work: df['Week_Nr'] = pd.to_numeric(df['Week_Nr'],errors='coerce')