Question
import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns import geopandas as gpd from sklearn.linear_model import LinearRegression #
import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns import geopandas as gpd from sklearn.linear_model import LinearRegression # Load the 311 requests dataset df = pd.read_csv("311_call_center_service_requests.csv") # Clean and preprocess the data df = df[['Neighborhood', 'Type of Service Request', 'Date Requested', 'Date Closed']] df['Date Requested'] = pd.to_datetime(df['Date Requested']) df['Date Closed'] = pd.to_datetime(df['Date Closed']) df['Time to Resolve (days)'] = (df['Date Closed'] - df['Date Requested']).dt.days df = df.dropna() df = df[df['Time to Resolve (days)'] >= 0] # Plot a map of the 311 requests gdf = gpd.GeoDataFrame(df, geometry=gpd.points_from_xy(df.longitude, df.latitude)) gdf.plot(markersize=0.1, figsize=(10,10)) # Group the requests by neighborhood and calculate the number and density of requests grouped = df.groupby('Neighborhood').size().reset_index(name='Number of Requests') grouped['Density of Requests'] = grouped['Number of Requests'] / grouped['Number of Requests'].sum() # Load socio-economic data for each neighborhood socio = pd.read_csv("socioeconomic_data.csv") grouped = pd.merge(grouped, socio, on='Neighborhood') # Use descriptive statistics to analyze the relationship between the socio-economic profiles and the number and density of 311 requests sns.pairplot(grouped, x_vars=['Median Income', 'Poverty Rate', 'Education Level'], y_vars=['Number of Requests', 'Density of Requests']) # Use regression analysis to investigate the relationship between the socio-economic profiles and the time it takes for the city to resolve 311 requests reg = LinearRegression().fit(grouped[['Median Income', 'Poverty Rate', 'Education Level']], grouped['Time to Resolve ( output for the above code
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started