If you need to delete some variables from the pandas dataframe, you can use the drop() function.
Here axis=0 means delete rows and axis=1 means delete columns.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# Defining Employee Data import pandas as pd EmployeeData=pd.DataFrame({'Name': ['ram','ravi','sham','sita','gita'], 'id': [101,102,103,104,105], 'Gender': ['M','M','M','F','F'], 'Age': [21,25,24,28,25] }) # Priting data print(EmployeeData) # Deleting few columns DeleteList=['Name','Gender'] EmployeeData=EmployeeData.drop(DeleteList, axis=1) # Priting data print(EmployeeData) |
Sample Output:

Author Details
Lead Data Scientist
Farukh is an innovator in solving industry problems using Artificial intelligence. His expertise is backed with 10 years of industry experience. Being a senior data scientist he is responsible for designing the AI/ML solution to provide maximum gains for the clients. As a thought leader, his focus is on solving the key business problems of the CPG Industry. He has worked across different domains like Telecom, Insurance, and Logistics. He has worked with global tech leaders including Infosys, IBM, and Persistent systems. His passion to teach inspired him to create this website!