I am working on a project where I want to detect the feature as nominal or ordinal type through a python script without any human intervention. Is this possible.
I am new to data science. your comments will help me
CodePudding user response:
A column like 'Age' does not represent nominal or ordinal data, but numerical data. You can find all columns that contain numerical data by using:
numeric_cols = df._get_numeric_data().columns # numeric columns
cols = df.columns # all columns
Let's say that columns that are not numeric are either nominal or ordinal (for example Gender) than you can find these columns with:
categorical_cols = list(set(cols) - set(numeric_cols))
If you want to identify nominal versus ordinal data, you would need to define some method for doing so. For example if you have ordinal data for clothing size (small, medium, large) you would have to define a fixed order first.