Esempio n. 1
0
def month_analysis(data):

    while True:
        print '\nPart 1 Instruction:\n'
        print 'Please enter valid year and month from 2013/7 to 2015/10. Year format: 2015, Month format: 7'
        print 'Enter back: return to main meun.'
        print 'Enter quit: exit this program.\n'
        year = raw_input('year? ')
        if year == 'quit':
            sys.exit()
        elif year == 'back':
            break
        month = raw_input('month? ')
        if month == 'quit':
            sys.exit()
        elif month == 'back':
            break
        if gf.check(year, month):
            year_int = int(year)
            month_int = int(month)
            print 'Please wait.......'
            data_month = gf.data_extract(data, year_int, month_int, year_int,
                                         month_int)
            object_plot = vs.visualizationTool(data_month, year_int, month_int)
            print 'Generating gender distribution pie plot...'
            object_plot.pieplot('gender')
            print 'Generating usertype distribution pie plot...'
            object_plot.pieplot('usertype')
            print 'Generating daily usage plot...'
            object_plot.plot_daily_freq(show_mile=False)
            print 'Generating daily miles plot...'
            object_plot.plot_daily_freq(show_mile=True)
        else:
            print '\nError: Please enter valid year and month!'
    return
Esempio n. 2
0
def month_analysis(data):

    while True:
        print '\nPart 1 Instruction:\n'
        print 'Please enter valid year and month from 2013/7 to 2015/10. Year format: 2015, Month format: 7'
        print 'Enter back: return to main meun.'
        print 'Enter quit: exit this program.\n'
        year = raw_input('year? ')
        if year == 'quit':
            sys.exit()
        elif year == 'back':
            break
        month = raw_input('month? ')
        if month == 'quit':
            sys.exit()
        elif month == 'back':
            break
        if gf.check(year, month):
            year_int = int(year)
            month_int = int(month)
            print 'Please wait.......'
            data_month = gf.data_extract(data, year_int, month_int, year_int, month_int)
            object_plot = vs.visualizationTool(data_month, year_int, month_int)
            print 'Generating gender distribution pie plot...'
            object_plot.pieplot('gender')
            print 'Generating usertype distribution pie plot...'
            object_plot.pieplot('usertype')
            print 'Generating daily usage plot...'
            object_plot.plot_daily_freq(show_mile=False)
            print 'Generating daily miles plot...'
            object_plot.plot_daily_freq(show_mile=True)
        else:
            print '\nError: Please enter valid year and month!'
    return
Esempio n. 3
0
def station_freq_visualization_main_function(data):
    """
    This function is going to use in main program, which will generate map plots for station frequency.
    """    

    while True:
        try:
            print '\n*****************************************************************'
            print '\nPart 2 Instruction:\n'
            print 'Please enter valid year and month from 2013/7 to 2015/10. Year format: 2015, Month format: 7\n'
            print 'Enter back: return to main meun.'
            print 'Enter quit: exit this program.\n'
            print '*****************************************************************\n'
            year = raw_input('Please enter a year: ')
            if year == 'back':
                break
            if year == 'quit':
                print '\nThanks, bye!'
                sys.exit()
            month = raw_input('Please enter a month: ')
            if month == 'back':
                break
            if month == 'quit':
                print '\nThanks, bye!'
                sys.exit()
            if not gf.check(year,month):
                raise InvalidInputError
            else:
                month = int(month)
                year = int(year)
                top_choice = 5 #shouw top 5 stations
                data_month = gf.data_extract(data, year, month, year, month)
                print '====> Calculating top 5 high frequency station...'
                loc_data = fs.station_info(data_month, year, month)
                print 'Show top 5 high frequency station:\n'
                stat_list = fs.high_freq_station(loc_data, top_choice)
                print stat_list
                map_plot_obj = sm.MapPlot(loc_data,month,year)
                with warnings.catch_warnings():
                    warnings.simplefilter("ignore")
                    print '\n====> Generating frequency map...'
                    map_plot_obj.draw_freq_map()
                    print '====> Generating high frequency map...'
                    map_plot_obj.draw_top_k_freq_map(top_choice)
                    print '====> Generating high heat map...'
                    map_plot_obj.draw_heat_map()


        except InvalidInputError:
            print '\nError: The input time is invalid!\n'
    return 
Esempio n. 4
0
def station_freq_visualization(data):
    while True:
        try:
            print "****************************************************"
            print '\nPart 2 Instruction:\n'
            print 'Please enter valid year and month from 2013/7 to 2015/10. Year format: 2015, Month format: 7'
            print 'Enter back: return to main meun.'
            print 'Enter quit: exit this program.\n'
            print "****************************************************"
            year = raw_input('year? ')
            if year == 'back':
                break
            if year == 'quit':
                sys.exit()
            month = raw_input('month?')
            if month == 'back':
                break
            if month == 'quit':
                sys.exit()
            if not gf.check(year,month):
                raise InvalidInputError
            else:
                month = int(month)
                year = int(year)
                top_choice = 5 #shouw top 5 stations
                data_month = gf.data_extract(data, year, month, year, month)
                print "Calculating top 5 high frequency station..."
                loc_data = fs.station_info(data_month, year, month)
                print "Show top 5 high frequency station:"
                stat_list = fs.high_freq_station(loc_data, top_choice)
                print stat_list
                map_plot_obj = mapplot.MapPlot(loc_data,month,year)
                with warnings.catch_warnings():
                    warnings.simplefilter("ignore")
                    print "Generating frequency map..."
                    map_plot_obj.draw_freq_map()
                    print "Generating high frequency map..."
                    map_plot_obj.draw_top_k_freq_map(top_choice)
                    print "Generating high heat map..."
                    map_plot_obj.draw_heat_map()


        except InvalidInputError:
            print "The input time is invalid"
    return 
Esempio n. 5
0
def station_freq_visualization(data):
    while True:
        try:
            print "****************************************************"
            print '\nPart 2 Instruction:\n'
            print 'Please enter valid year and month from 2013/7 to 2015/10. Year format: 2015, Month format: 7'
            print 'Enter back: return to main meun.'
            print 'Enter quit: exit this program.\n'
            print "****************************************************"
            year = raw_input('year? ')
            if year == 'back':
                break
            if year == 'quit':
                sys.exit()
            month = raw_input('month?')
            if month == 'back':
                break
            if month == 'quit':
                sys.exit()
            if not gf.check(year, month):
                raise InvalidInputError
            else:
                month = int(month)
                year = int(year)
                top_choice = 5  #shouw top 5 stations
                data_month = gf.data_extract(data, year, month, year, month)
                print "Calculating top 5 high frequency station..."
                loc_data = fs.station_info(data_month, year, month)
                print "Show top 5 high frequency station:"
                stat_list = fs.high_freq_station(loc_data, top_choice)
                print stat_list
                map_plot_obj = mapplot.MapPlot(loc_data, month, year)
                with warnings.catch_warnings():
                    warnings.simplefilter("ignore")
                    print "Generating frequency map..."
                    map_plot_obj.draw_freq_map()
                    print "Generating high frequency map..."
                    map_plot_obj.draw_top_k_freq_map(top_choice)
                    print "Generating high heat map..."
                    map_plot_obj.draw_heat_map()

        except InvalidInputError:
            print "The input time is invalid"
    return
Esempio n. 6
0
def month_analysis_main_function(data):
    """
    This function is going to use in main program, which will generate plots for monthly citibike data.
    """

    while True:
        print '\n**************************************************************'
        print '\nPart 1 Instruction:\n'
        print 'Please enter valid year and month from 2013/7 to 2015/10. Year format: 2015, Month format: 7\n'
        print 'Enter back: return to main meun.'
        print 'Enter quit: exit this program.\n'
        print '*****************************************************************\n'
        year = raw_input('Please enter a year: ')
        if year == 'quit':
            print '\nThanks, bye!'
            sys.exit()
        elif year == 'back':
            break
        month = raw_input('Please enter a month: ')
        if month == 'quit':
            print '\nThanks, bye!'
            sys.exit()
        elif month == 'back':
            break
        if gf.check(year, month):
            year_int = int(year)
            month_int = int(month)
            print 'Please wait.......'
            data_month = gf.data_extract(data, year_int, month_int, year_int, month_int)
            object_plot = vs.visualizationTool(data_month, year_int, month_int)
            print '====> Generating gender distribution pie plot...'
            object_plot.pieplot('gender')
            print '====> Generating usertype distribution pie plot...'
            object_plot.pieplot('usertype')
            print '====> Generating daily usage plot...'
            object_plot.plot_daily_freq(show_mile=False)
            print '====> Generating daily miles plot...'
            object_plot.plot_daily_freq(show_mile=True)
        else:
            print '\nError: Please enter valid year and month!\n'
    return