We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
convert_to_datetime
1 parent 3d5b43b commit 85f377aCopy full SHA for 85f377a
1 file changed
offsets_db_data/common.py
@@ -100,10 +100,12 @@ def convert_to_datetime(
100
"""
101
102
for column in columns:
103
- if column in df.columns:
104
- df[column] = pd.to_datetime(df[column], utc=utc, **kwargs).dt.normalize()
105
- else:
+ if column not in df.columns:
106
raise KeyError(f"The column '{column}' is missing.")
+ try:
+ df[column] = pd.to_datetime(df[column], utc=utc, **kwargs).dt.normalize()
107
+ except ValueError:
108
+ df[column] = pd.to_datetime(df[column], utc=utc).dt.normalize()
109
return df
110
111
0 commit comments