Posts

Showing posts with the label Sorting

CategoricalDtypes used in Filtering Data

Image
CategoricalDtypes in Pandas CategoricalDtypes can also be used for filtering.  For example, if we have low, high, and medium survey responses, we can use CategoricalDtypes to filter all responses less than or equal to medium. There are three basic steps! Create the CategoricalDtype. Apply the CategoricalDtype to the pandas Series. Filter the data. It is just that simple.  Let's look at an example. When we print the filtered_df, we can see we have our desired output.  It is just that simple! Link to Google Colab with the code!