Review 353-10 appoint list summary extended challenge

Extended challenge :
In this mission, we learned how to use the datetime module to work with date and time data. If you’d like some more practice, you can extend the work we did with this data set by:

Thinking about the maximum and minimum appointment time values, and exploring the data to explain why these values are larger than you might expect.
Find the visitor who spent the most amount of time at the White House.
Finding who visited the White House the most each month.
The final mission in this course is a Guided Project, where we’ll get to put all of the skills we’ve learned together in a real-world data scenario!

from operator import itemgetter, attrgetter
import calendar

appt_lengths = {}
for row in potus:
    end_date = row[3]
    end_date = dt.datetime.strptime(end_date, "%m/%d/%y %H:%M")
    row[3] = end_date
    appt_end_date = row[3]
    appt_start_date = row[2]
    df_timedelta = appt_end_date - appt_start_date
    if df_timedelta not in appt_lengths :
        appt_lengths[df_timedelta] = 1
        appt_lengths[df_timedelta] += 1
max_length = max(appt_lengths)
print("max appointment length",str(max_length))
min_length = min(appt_lengths)
print("min appointment length",str(min_length))

name_max = []
for row in potus:
    timedelta = row[3] - row[2]
    if timedelta == max_length:
#Find the visitor who spent the most amount of time at the White House    
print("Below guest have longest appointment")    
for i in name_max:
# x=potus[0][2]
# y=x.strftime("%B-%Y")
# type(y)

# name_date_freqency = {}

# for row in potus:
#     name = row[0]
#     start_time = row[2]
#     month = start_time.strftime("%m-%Y")
#     tmp="{}-{}".format(name,month)
#     if tmp not in name_date_freqency:
#         name_date_freqency[tmp] = 1
#     else:
#         name_date_freqency[tmp] += 1

# name_month_freq_list = []
# for key,value in  name_date_freqency.items():
#     name,month,year= key.split("-")
#     name_month_freq_list.append((name,int(month),year,value))
# y = sorted(name_month_freq_list, key=itemgetter(3),reverse = True)

month_wise_list = []
for mon in range(1,13):
    month_wise_guest_frequency = {}
    month_wise_guest_list = []
    for row in potus:
        name = row[0]
        start_time = row[2]
        month = int(start_time.strftime("%m"))
        if mon == month:
            if name not in month_wise_guest_frequency:
                month_wise_guest_frequency[name] = 1
                month_wise_guest_frequency[name] += 1
    for key,value in  month_wise_guest_frequency.items():
# print(sorted(month_wise_list[0],key= itemgetter(1),reverse = True ))

month_top_guest_list = []
for i in month_wise_list:
    month_list=sorted(i,key= itemgetter(1),reverse = True )
    month_top_guest = month_list[0]
# print(month_top_guest_list)

# print(len(month_top_guest_list))
# print(str(calendar.month_name[3]))
#Finding who visited the White House the most each month.
for i,guest in enumerate(month_top_guest_list):
    print("In {} guest \"{}\" has highest vist with count  {}".format(calendar.month_name[i+1],guest[0],guest[1]))


max appointment length 16 days, 12:59:00
min appointment length 2:29:00
Below guest have longest appointment
Regino B. Madrid
Glenn A. Dewey
Matthew J. Harding
Marquez D. Brown
Mark A. Questad
Marco A. Lopez
Marcio G. Botelho
Tilden E. Olsen
Oscar Romano
Glenn C. Paulson
Oscar A. Vanegasgonzalez
Nicholas A. Hubbard
Quemaine O. Tolar
Trevor H. Mowry
Peter J. Wilson
Robert C. Singer
Roland K. Felder
ShengTsung ■■■■
Gregory D. Ridlington
Michelle A. Rakers
Michael J. Robinson
David A. Murray
Max E. Cripe
Heather C. Zenobia
David J. Young
Frederick J. VareIII
Steven L. Owen
Scott M. Ninmer
Sarah M. Hart
Samuel M. Barlow
Tam T. Tran
Ryan J. Nowlin
Ryan H. McGeorge
Russell A. Wilson
William J. Back
Fern E. Sato
Francis C. Shieh
David W. Constantine
Daniel J. Schenk
Daniel E. Orban
Dakota L. Johnson
Courtney M. Morton
Cody A. ■■■
Clayton T. Bard
Tessa G. Vinson
Thomas J. MaloyJr
Ellen M. Dooley
Eric D. Sabo
Janet C. Bailey
Jane A. Cross
Deborah B. HansonGerber
Robert S. Delgadillo
Leslye L. Barrett
Elisabeth A. Plunk
Caroline E. Stute
Brian C. Turnmire
Brigette J. Knox
Bryan M. Walsh
Brad R. Weil
Alexander J. Linnert
Alan C. Prather
Aaron D. Clay
Benjamin J. Andrew
Jennifer L. Mills
Bernard G. Kolle
Christopher B. Reaves
Cameron M. Releford
Christopher J. McFarlane
Christopher J. Franke
Charles J. Paul
Charlaine L. Prescott
Chaerim K. Smith
Carlos H. Arrieta
Christopher P. Rose
Christopher E. Schmitt
Betsy J. Hill
Jennifer A. Paul
AnnaMaria R. Mottola
Jesus B. Torres
Jeremiah A. Morrison
Kyle A. Wyant
Kurt A. Dupuis
Kira M. Wharton
Kelvin M. Contreras
Karen A. Grimsey
Kara D. Santos
Jason K. Fettig
Jartavious B. Gunter
Jared E. Davidson
Elizabeth A. Matera
Karen L. Johnson
Dennon L. Audette
Devin M. Roseberry
Jose E. Arana
Joseph T. Crisp
Joseph G. Deluccio
John S. Whitt
Jeffrey M. Strouf
Juan P. Montoya
Joseph F. LeBlanc
Julio C. Tejedamotos
Joshua D. Figueredo
In January guest "Jesus MurilloKaram" has highest vist with count  3
In February guest "Sheila JacksonLee" has highest vist with count  5
In March guest "Linda N. Brettler" has highest vist with count  3
In April guest "Alan C. Prather" has highest vist with count  7
In May guest "Chris Coons" has highest vist with count  6
In June guest "Marilda W. Averbug" has highest vist with count  6
In July guest "Russell A. Wilson" has highest vist with count  4
In August guest "EMILY N. CAVNESS" has highest vist with count  3
In September guest "Shaojun ■■■■" has highest vist with count  6
In October guest "AnnaMaria R. Mottola" has highest vist with count  8
In November guest "ANDREW LISZEWSKI" has highest vist with count  3
In December guest "Brian E. Fallon" has highest vist with count  4

great challenge, thanks for the answer, my question is: what is the meaning behind those extended visit times??

Yeah, this is my question. I did a search on some of the top names, but none of the names turned up anything that would indicate that these people were of political importance. I did do a search on the dates and found that there was White House release indicating some holiday parties going on. It could be that these individuals were volunteers? I tried to cross reference this list with the volunteers that were listed on the White House release…no match. I did see we had a Mortal Kombat character attend the White House during this time, ShengTsung. Interestingly his name is redacted on this list. But, on my list it is not. His name is ShengTsung ■■■■ and he regularly attends the White House to play violin. I didn’t come up with anything on the other redacted name. I’m assuming that ShengTsung would have been paid for this event if he were playing for a holiday party. Maybe this is a list of contractors? That is people who don’t work at the White House, but might have still been considered guests. It would explain the stay time.