categorical

Combine multiple categorical columns into one, when each row has only one non-NaN value, in Pandas

Combine multiple categorical columns into one, when each row has only one non-NaN value, in Pandas Question: I have import pandas as pd import numpy as np df = pd.DataFrame({"x": ["red", "blue", np.nan, np.nan, np.nan, np.nan, np.nan, ], "y": [np.nan, np.nan, np.nan, ‘cold’, ‘warm’, np.nan, np.nan, ], "z": [np.nan, np.nan, np.nan, np.nan, np.nan, ‘charm’, ‘strange’], …

Total answers: 2

Convert Categorical features to Numerical

Convert Categorical features to Numerical Question: I have a lot of categorical columns and want to convert values in those columns to numerical values so that I will be able to apply ML model. Now by data looks something like below. Column 1- Good/bad/poor/not reported column 2- Red/amber/green column 3- 1/2/3 column 4- Yes/No Now …

Total answers: 2

Type Error: Cannot set item on a categorical with a new category

Type Error: Cannot set item on a categorical with a new category Question: I need to replace all values in the order column that are not equal to ‘no’, ‘n/a’ or ‘N/A’ by 1.0. I have tried converting it to a categorical variable and set the pre-existing categories as its distinct categories, but still get …

Total answers: 1