Forum Discussion
AutoML Data Type Error Preventing All Runs
- 1 year ago
Hi,
np.datetime64(nan, 'ns') will raise the exact error you're seeing, because NumPy is trying to interpret nan as a timestamp and failing.
You can perform this debugging steps to check for any nulls-print(X[time_col].head())
print(X[time_col].apply(type).value_counts())
print(X[time_col].isnull().sum())This will tell you what data types you actually have in that column.
Then proceed with this-
X[time_col] = pd.to_datetime(X[time_col], errors='coerce')
but make sure to call NumPy and Pandas asimport numpy as np
import pandas as pdHope this helps!
If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank You!
Hi pbi_is_ok,
The error you're seeing happens because some entries in your "Time" column are either missing or not in a valid date format. When Python tries to convert these invalid values into a date using np.datetime(x, "ns"), it fails—because it can't turn something like NaN(a float) into a datetime.
To fix this, you should use pd.to_datafeame() instead, which is a safer way to convert strings to datetime in pandas. It can handle bad values by turning them into NaT(Not a Time). After that, simply remove any rows where the date is invalid before continuing with your machine learning steps. This ensures you're only working with clean, usable date values.
Thanks,
Prashanth Are
- pbi_is_ok1 year agoNew Member
Hello,
I can confirm with 100% certainty that all of the values within the column are proper date data types and there are no null or missing values, so I don't think that is the issue. Also, it is ambiguous as to which command/cell the suggested code is supposed to be applied to.
- v-prasare1 year agoCommunity Support
Hi,
np.datetime64(nan, 'ns') will raise the exact error you're seeing, because NumPy is trying to interpret nan as a timestamp and failing.
You can perform this debugging steps to check for any nulls-print(X[time_col].head())
print(X[time_col].apply(type).value_counts())
print(X[time_col].isnull().sum())This will tell you what data types you actually have in that column.
Then proceed with this-
X[time_col] = pd.to_datetime(X[time_col], errors='coerce')
but make sure to call NumPy and Pandas asimport numpy as np
import pandas as pdHope this helps!
If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank You!