+ 1

After selecting a value in one cell from an excel table imported into python, how to refer to the value to the right of it?

I have an excel spreadsheet imported into python. The table contains the name and surname of the persons (eg: Alex), date of birth (eg: 26-08) and year of birth (eg: 1995). I need to write a function that returns a person whose birthday is correct by subtracting their year from the current year with their name "Dear Alex, Happy birthday with 27 age!" should result. name day year 0 Alex 26-08 1995 if day in df_day.values: print('Dear "name" , Happy birthday with "age"(current_year - df_year) age!')

26th Aug 2022, 10:49 AM
Raxmonjon Yusubjanov
3 odpowiedzi
+ 6
Raxmonjon Yusubjanov , i have tried to get your code to run. see your code and my suggestion and also the comments: https://code.sololearn.com/cRZwU8juvhE4/?ref=app
26th Aug 2022, 4:41 PM
Lothar
Lothar - avatar
+ 4
Okay, can you post your attempt?
26th Aug 2022, 11:12 AM
Slick
Slick - avatar
+ 2
import pandas as pd from datetime import datetime data = pd.read_excel(r'day.xlsx') df_day = pd.DataFrame(data, columns= ['day']) df_year = str(pd.DataFrame(data, columns = ['year'])) year = str(datetime.today().strftime('%Y')) in_day = input('input day: ') year = 2022 age = year - df_year if in_day in df_day.values: print('happy birthday with ' + age + 'age!') else: print("no birthday")
26th Aug 2022, 11:22 AM
Raxmonjon Yusubjanov