src.utils.fix_dtypes

Utility for fixing dtypes in a pandas DataFrame after reading from a CSV file.

Functions

fix_dtypes(data)

Fix the data types of the columns in a pandas DataFrame.

parse_float_list(arr)

Parse a string of floats into a list of floats.

parse_int_list(arr)

Parse a string of ints into a list of ints.

src.utils.fix_dtypes.parse_float_list(arr)[source]

Parse a string of floats into a list of floats.

Parse a string of floats into a list of floats. The string is expected to be formatted like “[1.0 2.0 3.0]”.

Parameters:

arr (str) – the string of floats.

Return type:

list[float]

Returns:

the list of floats.

src.utils.fix_dtypes.parse_int_list(arr)[source]

Parse a string of ints into a list of ints.

Parse a string of ints into a list of ints. The string is expected to be formatted like “[1 2 3]”.

Parameters:

arr (str) – the string of ints.

Return type:

list[int]

Returns:

the list of ints.

src.utils.fix_dtypes.fix_dtypes(data)[source]

Fix the data types of the columns in a pandas DataFrame.

Fix the data types of the columns in the DataFrame. The function will convert the columns to the correct data types. This is useful when reading data from a CSV file where the data types are not preserved.

Parameters:

data (DataFrame) – the DataFrame to fix the data types.

Return type:

DataFrame

Returns:

the DataFrame with the correct data types.