Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.83 KB | None | 0 0
  1. # coding=utf-8
  2.  
  3. __author__     = "Thomas & Amin"
  4. __build__      = "Thomas & Amin"
  5. __copyright__  = "Copyleft 2018 - SSI Efrei"
  6. __license__    = "GPL"
  7. __title__      = "TP Big Data en python"
  8. __version__    = "1.0.0"
  9. __maintainer__ = "Thomas & Amin"
  10. __email__      = "thomas.lounis@efrei.net"
  11. __status__     = "Production"
  12. __credits__    = "LOUNIS, BOUMEDIENE"
  13.  
  14.  
  15. import pandas as pd
  16.  
  17.  
  18. df = pd.read_excel('test.xlsx', sheet_name='Essais', skiprows=1)
  19.  
  20. df.drop(0, axis=0, inplace=True)
  21.  
  22. print "\n\nProjet de Big Data en Python\nEfrei Promo 2020 M1 SSI 1\nRealiser par Thomas Lounis et Amin Boumediene\n04/03/2019\nVersion: Finale\n\n\n"
  23.  
  24.  
  25.  
  26.  
  27.  
  28. print "Question 1\n"
  29.  
  30. for i, row in df.groupby('GROUP')['STUDENT'].nunique().iteritems():
  31.     print "there is {} students in the group {} \n".format(row, i)
  32.    
  33.    
  34. print "\n\nQuestion 2\n"
  35.  
  36. for i, row in df.groupby('GROUP')['TESTS'].sum().iteritems():
  37.     print "The group {} has made {} attempts \n".format(i, row)
  38.  
  39.    
  40. print "\n\nQuestion 3\n"
  41. tests = []
  42. groupes = []
  43. t = ()
  44. for i, row in df.groupby('GROUP')['TESTS'].sum().iteritems():
  45.     tests.append(row)
  46.     groupes.append(i)
  47.  
  48. z = zip(groupes, tests)
  49. t = max(z,key=lambda item:item[1])
  50.  
  51. x, _ = t
  52. _, y = t
  53. print "The group that has done the most attempts is the group {} with {} attempts\n".format(x, y)
  54.  
  55.  
  56.  
  57.  
  58. print "Question 1\n"
  59. total = df['TESTS'].sum()
  60. students = []
  61. students_unique = []
  62. for i in df.index:
  63.     students.append(df[u'ÉTUDIANT'][i])
  64. students = students[1:]
  65. students_unique = list(set(students))
  66. moyenne = total / len(students_unique)
  67. print "The average number of attempts per student is {} tests ".format(moyenne)
  68.    
  69.    
  70.  
  71. print "\n\nQuestion 1"
  72. for i, row in df.groupby('GROUPE')['EXO'].unique().iteritems():
  73.     print "\n\nthe group {} has made the following exercises: \n".format(i)
  74.     print (row)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement