Python Forum
kindly support with this dropna function not working
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
kindly support with this dropna function not working
#1
Shocked 
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.


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 possible
The 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.

Attached Files

.xlsx   PRACTICE WORK BOOK.xlsx (Size: 9.65 KB / Downloads: 94)
Reply


Messages In This Thread
kindly support with this dropna function not working - by gheevarpaulosejobs - Jul-23-2023, 07:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Excel isnt working properly after python function is started IchNar 2 323 May-01-2024, 06:43 PM
Last Post: IchNar
Exclamation Function Not Working Alivegamer 7 1,920 Jul-19-2022, 01:03 PM
Last Post: deanhystad
  try function working on PC but not raspberry pi AnotherSam 1 1,563 Oct-11-2021, 04:51 AM
Last Post: bowlofred
  Dropna not working WiPi 3 9,706 May-15-2020, 01:26 PM
Last Post: WiPi
  Kindly asking for help with Pywinauto louloulou 0 2,051 Mar-05-2020, 06:55 PM
Last Post: louloulou
  Input() function not working in VS Code darpInd 7 13,475 Feb-17-2020, 03:28 PM
Last Post: snippsat
  Unrelated new function causing existing working function to fail Nick_G 2 2,295 Jan-27-2020, 07:21 PM
Last Post: Nick_G
  User Defined function not working Raj_Kumar 4 3,066 Dec-17-2019, 12:44 PM
Last Post: buran
  Function not working eglaud 0 1,665 Oct-24-2019, 03:30 PM
Last Post: eglaud
  Kindly explain this error BlackList96 4 4,321 Jul-16-2019, 12:46 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020