Python Pandas Map function | Zip | Use of python dictionary for mapping the values of a column

preview_player
Показать описание
Python Pandas Map function | Zip | Use of python dictionary for mapping the values of a column

Python for Machine Learning - Session # 92

Topic to be covered - How to map dataset column using map function.

The map() function is used to map values of Series according to input correspondence.

Used for substituting each value in a Series with another value, that may be derived from a function, a dict or a Series.

Code Starts Here
===============

import pandas as pd

df = pd.DataFrame()

df['ID'] = [1111,2222,3333,4444,5555]
df['Name'] = ['Venkat','Sridhar','Shaqib','Nitin','Dupesh']
df['City'] = ['Hyderabad','Kolkata','Mumbai','Bangalore','Jaipur']

city_to_state = {'Hyderabad' :'Telangana',
'Kolkata':'West Bengal',
'Jaipur': ' Rajasthan',
'Bangalore': 'Karnataka',
'Mumbai': 'Maharastra'}

df['State'] = df['City'].map(city_to_state)

city_to_state1 = dict(zip(df2.City,df2.State))

df1['State'] = df1['City'].map(city_to_state1)

All the playlist of this youtube channel
========================================

1. Data Preprocessing in Machine Learning

2. Confusion Matrix in Machine Learning, ML, AI

3. Anaconda, Python Installation, Spyder, Jupyter Notebook, PyCharm, Graphviz

4. Cross Validation, Sampling, train test split in Machine Learning

5. Drop and Delete Operations in Python Pandas

6. Matrices and Vectors with python

7. Detect Outliers in Machine Learning

8. TimeSeries preprocessing in Machine Learning

9. Handling Missing Values in Machine Learning

10. Dummy Encoding Encoding in Machine Learning

11. Data Visualisation with Python, Seaborn, Matplotlib

12. Feature Scaling in Machine Learning

13. Python 3 basics for Beginner

14. Statistics with Python

15. Data Preprocessing in Machine Learning

16. Sklearn Scikit Learn Machine Learning

17. Linear Regression, Supervised Machine Learning

18 Interview Questions on Machine Learning, Artificial Intelligence, Python Pandas and Python Basics

19. Jupyter Notebook Operations
Рекомендации по теме
Комментарии
Автор

Excellent tutorial. Keep up uploading more such tutorials. All the best! 👍😃🌹

nizamuddinshaikh
Автор

What if key is missing from the dictionary and your trying to map it.?

rohitmohite
Автор

how about post the excel file in the scirpt?

liangyumin