get_columns¶
-
hhpy.ds.
get_columns
(df: pandas.core.frame.DataFrame, dtype: Union[Sequence[T_co], int, float, str, bytes, None, AbstractSet[T_co], numpy.number] = None, to_list: bool = False) → Union[list, pandas.core.indexes.base.Index][source]¶ A quick way to get the columns of a certain dtype. I added this because in pandas 1.0.0 pandas.DataFrame.select_dtypes(‘string’) sometimes throws an error when the column does not contain correctly formated data.
Parameters: - df – Pandas DataFrame containing the data, other objects are implicitly cast to DataFrame
- dtype – dtype to filter for, mimics behaviour of pandas.DataFrame.select_dtypes
- to_list – Whether to return a list instead of a pandas.Index
Returns: object containing the column names - if to_list: list, else pandas.Index