<jupyter_start><jupyter_text>Bubble Plot 1<jupyter_code># import dependencies
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# import csv files
city_data_complete = 'city_data.csv'
ride_data_complete = 'ride_data.csv'
# convert to data frame with pandas
city_data_df = pd.read_csv(city_data_complete)
ride_data_df = pd.read_csv(ride_data_complete)
# look at data
city_data_df.head()
# look at data
ride_data_df.head()
# sum fares by city
sum_fare = ride_data_df.groupby('city').sum()
sum_fare.head()
sum_fare = sum_fare.reset_index()

# total rides per city
number_fares = ride_data_df.groupby('city').count()
number_fares.head()
number_fares = number_fares.reset_index()
number_fares.head()
# # avg fare
# avg_fare = sum_fare['fare']/ number_fares['fare']
# avg_fare = avg_fare.values.tolist()
# merge data frames
merged_df = pd.merge(number_fares, sum_fare, on='city', how='inner')
merged_df.head()
# rename columns
merged_df = merged_df.rename(columns={'fare_x':'total rides',
                                      'fare_y':'total fare'
                                                            })
merged_df.head()
del merged_df['date']
del merged_df['ride_id_x']
del merged_df['ride_id_y'] 
# calulate average fare
merged_df['average fare'] = merged_df['total fare'] / merged_df['total rides']
merged_df.head()

# add city type
merged_df['type'] = city_data_df['type']
merged_df.head()
# plot
merged_df.plot(kind='scatter', x='total rides', y='average fare', 
               grid=True,title='Pyber Ride Sharing Data (2016)')
plt.show()
merged_df['type'].value_counts()
# .values.tolist()
# seperate Urban data
urban_data = merged_df.loc[merged_df['type'] == 'Urban', :]

urban_tot_rides = urban_data['total rides'].values.tolist()
urban_av_fare = urban_data['average fare'].values.tolist()

urban_data.head()

# seperate Suburban data
suburban_data = merged_df.loc[merged_df['type'] == 'Suburban', :]

suburban_tot_rides = suburban_data['total rides'].values.tolist()
suburban_av_fare = suburban_data['average fare'].values.tolist()

suburban_data.head()

# seperate Rural data
rural_data = merged_df.loc[merged_df['type'] == 'Rural', :]

rural_tot_rides = rural_data['total rides'].values.tolist()
rural_av_fare = rural_data['average fare'].values.tolist()

rural_data.head()
urban = (urban_tot_rides, urban_av_fare)
suburban = (suburban_tot_rides, suburban_av_fare)
rural = (rural_tot_rides, rural_av_fare)

data = (urban, suburban, rural)
colors = ('red', 'blue', 'green')
groups = ('Urban', 'Suburban', 'Rural')

# create plot

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, axisbg="1.0")
 
for data, color, group in zip(data, colors, groups):
    x, y = data
    ax.scatter(x, y, alpha=0.8, c=color, edgecolors='none', s=city_data_df['driver_count'], label=group)
      
ax.grid() 

plt.title('Pyber Ride Sharing Data (2016)')

plt.legend(loc='best')
# plt.figure(figsize=(20,10))
plt.show()
# data frame to list
total_rides = merged_df['total rides'].values.tolist()
average_fare = merged_df['average fare'].values.tolist()
city_type = merged_df['type'].values.tolist()
city_name = merged_df['city'].values.tolist()
# 
plt.scatter(total_rides, average_fare, marker="o", facecolors="red", edgecolors="black",
            s=total_rides, alpha=0.75)

# Create a title, x label, and y label for our chart
plt.title("Ice Cream Sales vs Temperature")
plt.xlabel("Temperature (Celsius)")
plt.ylabel("Sales (Dollars)")

show.plt()

N = 30
g1 = (0.6 + 0.6 * np.random.rand(N), np.random.rand(N))
g1<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15040764689344954, 'fraction_numerical': 0.008715209446162496, 'mean_word_length': 5.11340206185567, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '81586', 'license': 'MIT', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1277, 'n_words': 267, 'path': 'Pyber/raw_data/.ipynb_checkpoints/hw5_pyber-checkpoint.ipynb', 'repo_name': 'karawenz01/homework_5', 'size': '3557'}