Supprimer Ligne Python Dataframe
import pandas as pd
import numpy as np
# Importing numpy for NaN values
# Creating dataset using dictionary
dataset = {
'Name': ['Rohit', 'Arun', 'Sohit', 'Arun', 'Shubh'],
'Roll no': ['01', '02', '03', '04', np.nan],
'Maths': ['93', '63', np.nan, '94', '83'],
'Science': ['88', np.nan, '66', '94', np.nan],
'English': ['93', '74', '84', '92', '87']}
row_labels = ['a', 'b', 'c', 'd', 'e']
df = pd.DataFrame(data=dataset, index=row_labels)
print("DataFrame:\n", df)
print('Remove "Science" column from DataFrame')
removed = df.drop(['Science'], axis=1)
print("After Removing Science DataFrame:\n", removed)
>>>DataFrame:
Name Roll no Maths Science English
a Rohit 01 93 88 93
b Arun 02 63 NaN 74
c Sohit 03 NaN 66 84
d Arun 04 94 94 92
e Shubh NaN 83 NaN 87
Remove "Science" column from DataFrame
After Removing Science DataFrame:
Name Roll no Maths English
a Rohit 01 93 93
b Arun 02 63 74
c Sohit 03 NaN 84
d Arun 04 94 92
e Shubh NaN 83 87
Arbre