Python Pandas Tutorial | Drop Rows and Columns of a Pandas Dataset - P2
Topics to be covered:
1. Deleting rows of a dataset and copying the resultant dataset to a new dataframe - Completed
2. Drop the Duplicate Values
Code Starts Here
===============
import pandas as pd
import numpy as np
dataset = pd.read_csv('train.csv')
1 Dropping a Single Column of a dataset based on the column name
df1 = dataset.drop('Name',axis=1)
print(df1.head())
2.Dropping multiple Column of a dataset based on the column name
df1 = df1.drop(['Pclass','Cabin'],axis=1)
print(df1.head())
3. Dropping the Column of a dataset based on the Column Index
df1 = df1.drop(df1.columns[1],axis=1)
print(df1.head())
4. Dropping the Multiple Column of a dataset based on the Column Index
df2 = df1.drop(df1.columns[[1,3]],axis=1)
print(df2.head())
5. Deleting rows of a dataset and copying the resultant dataset to a new dataframe
df3 = df2.drop(df2.index[[1,3]])
print(df3.head())
6. Drop the Duplicate Values based on some conditions
df3 = df3[df3['Embarked'] != 'S'].head()
print(df3.head())
Dup = df3.drop_duplicates().head()
Dup = Dup.drop_duplicates(subset=['Embarked'])
print(Dup)
Dup1 = df3.drop_duplicates(subset=['Embarked'], keep='last')
print(Dup1)
All Playlist of this youtube channel
====================================
1. Data Preprocessing in Machine Learning
• Data Preprocessing in Machine Learnin...
2. Confusion Matrix in Machine Learning, ML, AI
• Confusion Matrix in Machine Learning,...
3. Anaconda, Python Installation, Spyder, Jupyter Notebook, PyCharm, Graphviz
• Anaconda | Python Installation | Spyd...
4. Cross Validation, Sampling, train test split in Machine Learning
• Cross Validation | Sampling | train t...
5. Drop and Delete Operations in Python Pandas
• Drop and Delete Operations in Python ...
6. Matrices and Vectors with python
• Matrices and Vectors with python
7. Detect Outliers in Machine Learning
• Detect Outliers in Machine Learning
8. TimeSeries preprocessing in Machine Learning
• TimeSeries preprocessing in Machine L...
9. Handling Missing Values in Machine Learning
• Handling Missing Values in Machine Le...
10. Dummy Encoding Encoding in Machine Learning
• Label Encoding, One hot Encoding, Dum...
11. Data Visualisation with Python, Seaborn, Matplotlib
• Data Visualisation with Python, Matpl...
12. Feature Scaling in Machine Learning
• Feature Scaling in Machine Learning
13. Python 3 basics for Beginner
• Python | Python 3 Basics | Python for...
14. Statistics with Python
• Statistics with Python
15. Sklearn Scikit Learn Machine Learning
• Sklearn Scikit Learn Machine Learning
16. Python Pandas Dataframe Operations
• Python Pandas Dataframe Operations
17. Linear Regression, Supervised Machine Learning
• Linear Regression | Supervised Machin...
18 Interiew Questions on Machine Learning and Data Science
• Interview Question for Machine Learni...
19. Jupyter Notebook Operations
• Jupyter and Spyder Notebook Operation...