Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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:
", df)

print('Remove "Science" column from DataFrame')
removed = df.drop(['Science'], axis=1)
print("After Removing Science DataFrame:
", 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

Comment

PREVIOUS NEXT
Code Example
Python :: vscode not recognizing python import 
Python :: python get everything between two characters 
Python :: printing a range of no one line in python 
Python :: delete turtle 
Python :: two input number sum in python 
Python :: trump 
Python :: pandas groupby get all but first row 
Python :: python selenium assert presence of an element 
Python :: fiel to base64 python 
Python :: python continue vs pass 
Python :: pygame window 
Python :: get information about dataframe 
Python :: source code of Tortoise and hare algorithm in python 
Python :: get local python api image url 
Python :: max of a dict 
Python :: pyautogui pause in python 
Python :: Set column as index with pandas 
Python :: Get Key From value in dictionary 
Python :: extract link from text python 
Python :: python snake game 
Python :: pandas object to float 
Python :: Parameter Grid python 
Python :: time counter in python 
Python :: pandas to pickle 
Python :: how to show webcam in opencv 
Python :: python remove all except numbers 
Python :: python is integer 
Python :: python element wise multiplication list 
Python :: how to sort in greatest to least python 
Python :: convert number to binary in python 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =