Advertisement
Klaudia_Kacperska

Untitled

Nov 14th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. def dataStatistics(self):
  2. while True:
  3. print('Options:')
  4. print('1. Mean Temperature:\nMean (average) Temperature.')
  5. print('\n2. Mean Growth Rate: \nMean (average) Growth Rate.')
  6. print('\n3. Std Temperature:\nStandard deviation of Temperature.')
  7. print('\n4. Std Growth rate:\nStandard deviation of Growth rate.')
  8. print('\n5. Rows:\nThe total number of rows in the data.')
  9. print('\n6. Mean Cold Growth rate:\nAverage Growth rate for Temperature below 20 degrees.')
  10. print('\n7. Mean Hot Growth rate:\nAverage Growth rate for Temperature above 50 degrees.')
  11. statistics = input("choose statistic:\n")
  12. result = 0
  13. if self.l.empty == True:
  14. print('Statistics can not be computed when all data is filtered')
  15. return
  16. if statistics in ['1', 'Mean Temperature', 'mean temperature', 'mean Temperature', 'mt', 'MT']:
  17. result = np.mean(np.array(self.l.iloc[:, 2]))
  18.  
  19. elif statistics in ['2', 'Mean Growth rate', 'MGR', 'mgr']:
  20. result = np.mean(np.array(self.l.iloc[:, 1]))
  21.  
  22. elif statistics in ['3', 'Std Temperature', 'ST', 'st']:
  23. result = np.std(np.array(self.l.iloc[:, 2]))
  24.  
  25. elif statistics in ['4', 'Std Growth rate', 'std GT', 'STD GT']:
  26. result = np.std(np.array(self.l.iloc[:, 1]))
  27.  
  28. elif statistics in ['5', 'Rows', 'rows', 'rs']:
  29. result = len(np.array(self.l.iloc[:, 0]))
  30.  
  31. elif statistics in ['6', 'Mean Cold Growth Rate', 'mean cold growth rate', 'mcgr', 'MCGR']:
  32. Sum = 0
  33. n = 0
  34. for i in range(len(self.l.iloc[:, 1])):
  35. if self.l.iloc[i, 2] < 20:
  36. n += 1
  37. Sum += self.l.iloc[i, 1]
  38. if n <= 0:
  39. print('no data below 20 degrees found')
  40. else:
  41. result = Sum / n
  42.  
  43. elif statistics in ['7', 'Mean Hot Growth Rate', 'mean hot growth rate', 'mhgr', 'MHGR']:
  44. Sum = 0
  45. n = 0
  46. for i in range(len(self.l.iloc[:, 1])):
  47. if self.l.iloc[i, 2] > 50:
  48. n += 1
  49. Sum += self.l.iloc[i, 1]
  50. if n <= 0:
  51. print('no data above 50 degrees found')
  52. else:
  53. result = Sum / n
  54.  
  55. elif statistics in ['Q', 'q', 'Quit', 'quit', 'r', 'R', 'Return', 'return']:
  56. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement