Jul-23-2023, 07:14 PM
(This post was last modified: Jul-24-2023, 10:56 AM by Gribouillis.)
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.
Gribouillis write Jul-24-2023, 10:56 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Attached Files
PRACTICE WORK BOOK.xlsx (Size: 9.65 KB / Downloads: 99)