-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.py
33 lines (26 loc) · 989 Bytes
/
script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
this script opens an excel file, in the pre-specified path, and parses it.
"""
import pandas as pd
from datetime import datetime
# Now 'df' contains the data from your Excel file
def parse_bday(df):
# Extract the month, day, and year
df['month'] = df['Birthday'].str[:2]
df['day'] = df['Birthday'].str[2:4]
df['year'] = '2000'
new_df = df[['month', 'day', 'year']]; new_df
# convert birthday dates to the appropriate format. NaT if previously NaN
df['Birthday'] = pd.to_datetime(new_df, errors='coerce')
return df
def bdays_this_month(df):
"""
assumes the 'Birthday' column is formated as a datetime object. returns dataframe
"""
current_date = datetime.now()
current_month = current_date.month
same_month_rows = df[df['Birthday'].dt.month == current_month]
month_data = same_month_rows[["First Name", "Last Name", "day", "month"]]
return month_data
def names_str(df):
return ', '.join(list(df["First Name"]))