we are Developing Relationship... and Expose Results.
Data Pre-processing – Encoding with applymap in Pandas
Data pre-processing is one of the important steps as it is not only time consuming but also critical for any business if we think about predictions. Encoding is one of the important steps in the data pre-processing which will help us to convert the text data to numerical data.
In the text data, we can have data like Nominal (No rank associated with it i.e. State, City, Gender, etc.) or Ordinal (Rank associated with it i.e. Excellent, Good, Bad, Poor). We need to encode based on the data. For example, (show below in the table) of the data is nominal we are okay to encode randomly or alphabetically, however, if the data is ordinal we would prefer to encode the data rank wise. This approach can be used for the same as well. However, we are helping us understand how the encoding can be done and from there we will able to understand how we can take care of ordinal data as well.
If you are interested in the ordinal data encoding with another way there is a columntransfomer from the scikit learn technique which will be quicker as well to deal with the encoding problems.
In the below table we can see there are two categorical columns Gender and Region, we want to encode as per our requirements and not alphabetically. Let’s say we want below values as the encoded values:
Here are the steps which we will apply to do the desired encoding. We are using apply map from Pandas to achieve the same.
We can see the output is the same as what we are looking for. Hope this makes sense. Hope to see you on the next blog till Happy Analyzing.
Presenting Pace Charts in Tableau
Pace charts is an innovative bullet graph design that normalizes development of target visualizations through KPIs, though the KPIs have extraordinary information seasonal trends, formats and/or scales…Know More
Instructions to Color Entire Tableau Charts Based on Latest Performance
Since the stock market in recent weeks has been so unpredictable, we’ve seen plenty of sparklines showing the daily results for a symbol or index…Know More
Have any Question? Call Us..
(+ 91) 9356237404