-2

After sucking names and hours worked out of a csv file is search for anyone working more the 46 hours. Once i find them how do i rejoin hours with person.

df = pd.read_csv('C:/Users/richard/EWW/Team_ Terran - Richard_2022-05-01_2022-05-31)
#"Full name" and "Hours" are column headers 
agg_hours = df.groupby(['Full name'])['Hours'].sum()
FullName = list(dict.fromkeys(FullName)) 
print(agg_hours)
Full name
Adam  T           40.00
Bryan F           42.75
Dylan S           43.00
Eric E            16.00
Henry N           48.50
Jacob M           42.00
Johnny T          49.25
Paras M           15.50
Paul C            50.00
Reed W            49.75
Sid M             6.00
Vir  P            46.50
Name: Hours, dtype: float64
for i in range(12):
    hrs=agg_hours[i]
    if hrs > 46:
     print(hrs)
48.5
49.25
50.0
49.75
46.5
  • You're missing a `')` on the first line, maybe more. Please [edit] to fix the formatting. If you need help, check out the [formatting help](/editing-help) or LMK. – wjandrea May 10 '22 at 21:26
  • On second thought, I was able to fix some of the formatting for you. – wjandrea May 10 '22 at 21:28
  • 1
    If you do `agg_hours = df.groupby('Full name', as_index=False).sum('Hours')`, then `agg_hours` is a proper df and you can do the standard [selection by column value](/questions/17071871/how-do-i-select-rows-from-a-dataframe-based-on-column-values). So I think your question is essentially a duplicate, but LMK if not. – wjandrea May 10 '22 at 21:46

0 Answers0