7/6/17 Notes (Trying to find total attendance)

I want to add a command that will add all the numbers in the attendance column together for one person.
  • I tried this command I found online:
    • StudentinfoAll.loc[StudentinfoAll['Full Name'] == 'Ella Hubbell', 'Attendance'].sum()
    • I got an error saying “Attendance’ is not in the columns” but is a column header
    • I looked at the chart that I made and there are multiple Attendance columns so I tried typing “Attendance_x” instead.
    • This didn’t add them it just put the numbers together into the number “10109”
  • I tried this command instead:
    • StudentinfoAll.sum(axis = {‘Georgianna Bamberger’,'Attendance_x'} skipna=None)
    • This did not work.
    • I deleted the skipna part because it was “invalid syntax”
    • I got an error saying this was “unhashable” so I changed the format of the cells in the Attendance file to “text” and reuploaded the file. This did not worked.
    • I replaced Georgianna Bamberger’s name, and ‘Attendance’ with the numbers that correspond with where the labels are on the chart.
  • I tried this command because I want my code to add the values in Attendance if the full name is Georgianna Bamberger. Here is what I typed:
    • StudentinfoAll.sum('Attendance_x' if 'Full Name' = Georgianna Bamberger)
    • I’m having problems with the syntax of 'Full Name' = Georgianna Bamberger
    • I tried this instead: StudentinfoAll.sum('Attendance_x' if 'Georgianna Bamberger' in 'Full Name'). This did not work.
    • I tried StudentinfoAll.sum('Attendance_x') just to see if it would add all the attendance values together but ‘Attendance_x’ is not an axis so I need to learn how to format this as an axis, or find a different command.
  • I tried following the exact pattern of the example online just to see what would happen, so I could edit it from there. Here is what I typed.
    • StudentinfoAll.sum(axis = {index(0), columns(1)})
    • “Index” was not defined so I replaced it with ‘Full Name’ this did not work because the string is “not callable” (which means it can’t be called)
  • Apparently in pandas “axis=0” means you’re adding the values of a column.
  • I typed “StudentinfoAll.sum(axis = 0)” to see what would happen and it listed out each column name and their sum (if the columns had numbers).
  • I tried typing “StudentinfoAll.sum(axis = 0, 'Attendance_x')” to see if it would add all the values for just the attendance column. This did not work.
  • I tried this “StudentinfoAll.sum(axis = 0 ['Atendance'])” this did not work.
  • Tried this command: “StudentinfoAll.sum('Attendance_x', axis = 0)” this did not work
  • Tried “StudentinfoAll.sum(axis = 0, if column='Attendance_x')” invalid syntax
  • Tried “StudentinfoAll.sum(axis = 0) if column = 'Attendance_x'” invalid syntax
  • Tried “StudentinfoAll['Attendance_x'].sum(axis = 0)” this gave me the sum of all the attendance values, now I just have to find a way to have it add the attendance values for just a specific person.
  • Tried this command:
    • StudentinfoAll[[Attendance['Georgianna Bamberger']]].sum(axis = 0)
    • The key error was ‘Georgianna Bamberger’ so I restarted Kernel and cleared all outputs. This did not work, I think because her name is under “Full Name” not Attendance.
  • Tried this command:
    • StudentinfoAll[[960,1010,1071],['Attendance']].sum(axis=0)
    • The numbers are the rows where her name appears
    • This did not work because it’s a “list”
  • Tried this command:
    • if StudentinfoAll['Full Name']='Georgianna Bammberger'
   StudentinfoAll['Attendance_x'].sum(axis=0)

    • This did not work
  • I made the code display just Georgianna Bamberger’s name and attendance for each year and I found that apparently there are two columns named “Attendance_x” and that might be messing up the code.
  • Tried this command
    • StudentinfoAll['Attendance_x'].sum(axis=0) for StudentinfoAll.rows[960,1010,1071]
  • I tried this command:
    • StudentinfoAll[StudentinfoAll['Full Name'] == '<Georgianna Bamberger>']['Attendance_x'].sum()
    • This told me the sum was 0 which is wrong. I wonder if I need to change the format of the cells in the attendance file into something other than “text”
    • I changed the format to numbers and this did not work.
  • Tried this
    • StudentinfoAll.groupby('Full Name').agg({'Attendance_x': np.sum})
    • This just alphabetized the names, deleted the data, and didn’t display the sum

Comments

Popular posts from this blog

6/14/17 Notes

6/06/17 Notes (formatting code and searching for a specific person)

May 22, 2017 -- SienaSemanticsSurvey -- Code Breakdown -- Cell #8