Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.48 KB | None | 0 0
  1. ## Use this and additional cells to continue to explore the dataset. ##
  2. ## Once you have performed your exploration, document your findings  ##
  3. ## in the Markdown cell above.                                       ##
  4.  
  5. filename='./data/Washington-2016-Summary.csv'
  6. def monthly_riders(filename):
  7.     with open(filename, 'r') as f_in:
  8.         reader = csv.DictReader(f_in)
  9.         month_dict={'January':[],
  10.                     'February':[],
  11.                     'March':[],
  12.                     'April':[],
  13.                     'May':[],
  14.                     'June':[],
  15.                     'July':[],
  16.                     'August':[],
  17.                     'September':[],
  18.                     'October':[],
  19.                     'November':[],
  20.                     'December':[]}
  21.        
  22.         for row in reader:
  23.             if(row['month']=='1'):
  24.                 month_dict['January'].append(row['duration'])
  25.             elif(row['month']=='2'):
  26.                 month_dict['February'].append(row['duration'])
  27.             elif(row['month']=='3'):
  28.                 month_dict['March'].append(row['duration'])
  29.             elif(row['month']=='4'):
  30.                 month_dict['April'].append(row['duration'])
  31.             elif(row['month']=='5'):
  32.                 month_dict['May'].append(row['duration'])
  33.             elif(row['month']=='6'):
  34.                 month_dict['June'].append(row['duration'])
  35.             elif(row['month']=='7'):
  36.                 month_dict['July'].append(row['duration'])
  37.             elif(row['month']=='8'):
  38.                 month_dict['August'].append(row['duration'])
  39.             elif(row['month']=='9'):
  40.                 month_dict['September'].append(row['duration'])
  41.             elif(row['month']=='10'):
  42.                 month_dict['October'].append(row['duration'])
  43.             elif(row['month']=='11'):
  44.                 month_dict['November'].append(row['duration'])
  45.             elif(row['month']=='12'):
  46.                 month_dict['December'].append(row['duration'])
  47.         trip_monthly_counts=[len(month_dict['January']),len(month_dict['February']),len(month_dict['March']),len(month_dict['April']),len(month_dict['May']),len(month_dict['June']),len(month_dict['July']),len(month_dict['August']),len(month_dict['September']),len(month_dict['October']),len(month_dict['November']),len(month_dict['December'])]
  48.         return trip_monthly_counts
  49.        
  50.    
  51.  
  52.    
  53. #print(monthly_riders(filename))
  54. data=monthly_riders(filename)
  55. print(data)
  56.  
  57. plt.plot(data)
  58. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement