seismometer.data.pandas_helpers.try_casting

seismometer.data.pandas_helpers.try_casting(dataframe, column, column_dtype)

Attempts to cast a column to a specified data type inplace.

Will convert the specified column to a data type, raising a ConfigurationError if the conversion fails. Does multistep casts to get strings “1.0” into format int 1.

Parameters:
  • dataframe (pd.DataFrame) – The dataframe to modify.

  • column (str) – The column to cast.

  • column_dtype (str) – The data type to cast the column to.

Raises:

ConfigurationError – If the column cannot be cast to the specified data type.

Return type:

None