Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _cast_pandas(dataframe: pd.DataFrame, cast_columns: Dict[str, str]) -> pd.DataFrame:
for col, athena_type in cast_columns.items():
pandas_type: str = data_types.athena2pandas(dtype=athena_type)
if pandas_type == "datetime64":
dataframe[col] = pd.to_datetime(dataframe[col])
elif pandas_type == "date":
dataframe[col] = pd.to_datetime(dataframe[col]).dt.date.replace(to_replace={pd.NaT: None})
else:
dataframe[col] = dataframe[col].astype(pandas_type, skipna=True)
return dataframe
def _cast_pandas(dataframe: pd.DataFrame, cast_columns: Dict[str, str]) -> pd.DataFrame:
for col, athena_type in cast_columns.items():
pandas_type: str = data_types.athena2pandas(dtype=athena_type)
if pandas_type == "datetime64":
dataframe[col] = pd.to_datetime(dataframe[col])
elif pandas_type == "date":
dataframe[col] = pd.to_datetime(dataframe[col]).dt.date.replace(to_replace={pd.NaT: None})
else:
dataframe[col] = dataframe[col].astype(pandas_type, skipna=True)
return dataframe