Skip to content

Instantly share code, notes, and snippets.

Elijah Ayeeta

Block or report user

Report or block Ayeeta

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Ayeeta
Ayeeta / median_poverty.py
Created Sep 18, 2019
Visualize relationship between median household income and poverty levels
View median_poverty.py
# Create figure with secondary y-axis
fig = make_subplots(specs=[[{"secondary_y": True}]])
# Add traces
fig.add_trace(
go.Scatter(x=states['State'], y=states['POVALL_2017'], name="Poverty Estimates 2017"),
secondary_y=False,
)
fig.add_trace(
@Ayeeta
Ayeeta / choropleth.py
Created Sep 18, 2019
visualize poverty levels on US map
View choropleth.py
states['text'] = "Poverty Estimates 2017"+"\
"+ states["POVALL_2017"].astype(str) + " " +"State:" +" \
"+ states["Area_Name"]
fig = go.Figure(data=go.Choropleth(
locations=states['State'], # Spatial coordinates
z = states["POVALL_2017"].astype(float), # Data to be color-coded
locationmode = 'USA-states', # set of locations match entries in `locations`
colorscale = 'greens',
text = states['text'],
@Ayeeta
Ayeeta / poverty_data_2017.py
Created Sep 18, 2019
Visualize POVALL_2017 against State
View poverty_data_2017.py
poverty_data_2017 = px.line(states, x='State', y='POVALL_2017', title='Poverty Estimates 2017')
poverty_data_2017.show()
@Ayeeta
Ayeeta / null_states.py
Created Sep 18, 2019
sum of null values in the states data frame
View null_states.py
#let's see columns with null values
states.apply(lambda x: sum(x.isnull()), axis=0)
@Ayeeta
Ayeeta / states.py
Created Sep 18, 2019
states data frame
View states.py
#get all state rows using Area_Name
area_name = ['Alabama','Alaska','Arizona', 'Arkansas','California','Colorado','Connecticut','Delaware',
'Florida','Georgia','Hawaii','Idaho','Illinois','Indiana','Iowa','Kansas','Kentucky','Louisiana',
'Maine','Maryland','Massachusetts','Michigan','Minnesota','Mississippi','Missouri','Montana','Nebraska',
'Nevada','New Hampshire','New Jersey','New Mexico','New York','North Carolina','North Dakota','Ohio',
'Oklahoma','Oregon','Pennsylvania','Rhode Island','South Carolina','South Dakota','Tennessee','Texas',
'Utah','Vermont','Virginia','Washington','West Virginia','Wisconsin','Wyoming']
states = poverty_data.loc[poverty_data['Area_Name'].isin(area_name)]
states.head()
@Ayeeta
Ayeeta / null_values.py
Created Sep 18, 2019
Check sum of null values in columns
View null_values.py
#let's see columns with null values
poverty_data.apply(lambda x: sum(x.isnull()), axis=0)
@Ayeeta
Ayeeta / head.py
Created Sep 18, 2019
First five rows of the data frame
View head.py
poverty_data.head()
View poverty_data.py
poverty_data = pd.read_csv('povertyData.csv')
@Ayeeta
Ayeeta / imports.py
Created Sep 18, 2019
Import Libraries
View imports.py
from matplotlib.pyplot import figure
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from pandas import DataFrame
from plotly.subplots import make_subplots
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import plotly.express as px
import plotly.graph_objects as go
@Ayeeta
Ayeeta / pop_desc.py
Created Sep 11, 2019
describe population_data dataframe
View pop_desc.py
population_data.describe()
You can’t perform that action at this time.