Jul-23-2023, 07:14 PM
Hello,
I am beginner in python. This is my code.
In line 12, i wrote a "dropna" function to avoid a row having a blank field in the column named "documented". but still the "nan: appearing while printing it. kindly help please.
I am beginner in python. This is my code.
In line 12, i wrote a "dropna" function to avoid a row having a blank field in the column named "documented". but still the "nan: appearing while printing it. kindly help please.
file_name = "C:/Users/Gheevar/Documents/PYTHON CLASS/home study/PRACTICE WORK BOOK.xlsx" sheet = "Sheet1" ###Sheet name import pandas as pd ##pandas df = pd.read_excel(io=file_name, sheet_name=sheet) df['SPECIALITY'] = df['SPECIALITY'].str.lower() ##converting specality to lower case pd.set_option('display.max_columns', None) ##to display all columns below pd.set_option('display.max_rows', None) ##to display all rows below df.replace({"SPECIALITY":["pediatric trauma","trauma surgery","ortho_trauma"]}, "trauma") ##replacing values df.dropna(subset = ['DOCUMENTED'], inplace=True) ##remove the line having blank value in documented column print(df) df.pivot(index= 'DOCUMENTED', columns='SPECIALITY', values="PT URN") ## The pivot table also not appearing for me while am writing this code. kindly help this also if possibleThe excel data what am using is attached here.