home/bikeshare.py
def user_stats(df):
    """Displays statistics on bikeshare users."""

    print('\nCalculating User Stats...\n')
    start_time = time.time()

    # TO DO: Display counts of user types
    Subscribers = len(df[df["User Type"] == "Subscriber"])
    Customers = len(df[df["User Type"] == "Customer"])
    print ('subscribers:' , Subscribers, sep = " ")
    print ('customers:', Customers, sep = " ")


    # TO DO: Display counts of gender
    try:    
        Males = len(df[df["Gender"] == "Male"])
        Females = len(df[df["Gender"] == "Female"])
    except:    
        print('There is no Gender data')
    else:
        print('Males :', Males, sep = " ")
        print('Females :', Females, sep = " ")


    # TO DO: Display earliest, most recent, and most common year of birth
    try:    
        earliest = df['Birth Year'].min() 
        most_recent = df['Birth Year'].max()
        most_common = df['Birth Year'].mode()
    except:
        print('There is no Birth Year data')
    else:
        print ('Earliest :', earliest, sep = " ")
        print ('Most recent :', most_recent, sep = " ")
        print ('Most common :', most_common, sep = " ")

        print("\nThis took %s seconds." % (time.time() - start_time))
        print('-'*40)
Displays statistics on bikeshare users.
Displays statistics on bikeshare users.
Displays statistics on bikeshare users .
def user_stats(df):
    print('\nCalculating User Stats...\n')
    start_time = time.time()
    Subscribers = len(df[df["User Type"] == "Subscriber"])
    Customers = len(df[df["User Type"] == "Customer"])
    print ('subscribers:' , Subscribers, sep = " ")
    print ('customers:', Customers, sep = " ")
    try:    
        Males = len(df[df["Gender"] == "Male"])
        Females = len(df[df["Gender"] == "Female"])
    except:    
        print('There is no Gender data')
    else:
        print('Males :', Males, sep = " ")
        print('Females :', Females, sep = " ")
    try:    
        earliest = df['Birth Year'].min() 
        most_recent = df['Birth Year'].max()
        most_common = df['Birth Year'].mode()
    except:
        print('There is no Birth Year data')
    else:
        print ('Earliest :', earliest, sep = " ")
        print ('Most recent :', most_recent, sep = " ")
        print ('Most common :', most_common, sep = " ")
        print("\nThis took %s seconds." % (time.time() - start_time))
        print('-'*40)
def user_stats ( df ) : print ( '\nCalculating User Stats...\n' ) start_time = time . time ( ) Subscribers = len ( df [ df [ "User Type" ] == "Subscriber" ] ) Customers = len ( df [ df [ "User Type" ] == "Customer" ] ) print ( 'subscribers:' , Subscribers , sep = " " ) print ( 'customers:' , Customers , sep = " " ) try : Males = len ( df [ df [ "Gender" ] == "Male" ] ) Females = len ( df [ df [ "Gender" ] == "Female" ] ) except : print ( 'There is no Gender data' ) else : print ( 'Males :' , Males , sep = " " ) print ( 'Females :' , Females , sep = " " ) try : earliest = df [ 'Birth Year' ] . min ( ) most_recent = df [ 'Birth Year' ] . max ( ) most_common = df [ 'Birth Year' ] . mode ( ) except : print ( 'There is no Birth Year data' ) else : print ( 'Earliest :' , earliest , sep = " " ) print ( 'Most recent :' , most_recent , sep = " " ) print ( 'Most common :' , most_common , sep = " " ) print ( "\nThis took %s seconds." % ( time . time ( ) - start_time ) ) print ( '-' * 40 )
Displays statistics on bikeshare users.
Displays statistics on bikeshare users .
"""Displays statistics on bikeshare users.""" # TO DO: Display counts of user types # TO DO: Display counts of gender # TO DO: Display earliest, most recent, and most common year of birth
df