How to Use where() in Python Pandas

Free Pandas course with real-time projects Start Now!!

Program 1

import pandas as pd
df=pd.read_excel("E:\mypandas\mydata.xlsx",sheet_name='Result')
print(df)
print("---------------After Where--------------")
df.set_index('Name',inplace=True)

#print(df.where(df<75,'First'))
#print(df.where(df['HSC']<75,'First'))
df1=df.where(lambda x: x < 80, 'A+')
print(df1)

 

You give me 15 seconds I promise you best tutorials
Please share your happy experience on Google

follow dataflair on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *