Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def dataStatistics(self):
- while True:
- print('Options:')
- print('1. Mean Temperature:\nMean (average) Temperature.')
- print('\n2. Mean Growth Rate: \nMean (average) Growth Rate.')
- print('\n3. Std Temperature:\nStandard deviation of Temperature.')
- print('\n4. Std Growth rate:\nStandard deviation of Growth rate.')
- print('\n5. Rows:\nThe total number of rows in the data.')
- print('\n6. Mean Cold Growth rate:\nAverage Growth rate for Temperature below 20 degrees.')
- print('\n7. Mean Hot Growth rate:\nAverage Growth rate for Temperature above 50 degrees.')
- statistics = input("choose statistic:\n")
- result = 0
- if self.l.empty == True:
- print('Statistics can not be computed when all data is filtered')
- return
- if statistics in ['1', 'Mean Temperature', 'mean temperature', 'mean Temperature', 'mt', 'MT']:
- result = np.mean(np.array(self.l.iloc[:, 2]))
- elif statistics in ['2', 'Mean Growth rate', 'MGR', 'mgr']:
- result = np.mean(np.array(self.l.iloc[:, 1]))
- elif statistics in ['3', 'Std Temperature', 'ST', 'st']:
- result = np.std(np.array(self.l.iloc[:, 2]))
- elif statistics in ['4', 'Std Growth rate', 'std GT', 'STD GT']:
- result = np.std(np.array(self.l.iloc[:, 1]))
- elif statistics in ['5', 'Rows', 'rows', 'rs']:
- result = len(np.array(self.l.iloc[:, 0]))
- elif statistics in ['6', 'Mean Cold Growth Rate', 'mean cold growth rate', 'mcgr', 'MCGR']:
- Sum = 0
- n = 0
- for i in range(len(self.l.iloc[:, 1])):
- if self.l.iloc[i, 2] < 20:
- n += 1
- Sum += self.l.iloc[i, 1]
- if n <= 0:
- print('no data below 20 degrees found')
- else:
- result = Sum / n
- elif statistics in ['7', 'Mean Hot Growth Rate', 'mean hot growth rate', 'mhgr', 'MHGR']:
- Sum = 0
- n = 0
- for i in range(len(self.l.iloc[:, 1])):
- if self.l.iloc[i, 2] > 50:
- n += 1
- Sum += self.l.iloc[i, 1]
- if n <= 0:
- print('no data above 50 degrees found')
- else:
- result = Sum / n
- elif statistics in ['Q', 'q', 'Quit', 'quit', 'r', 'R', 'Return', 'return']:
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement