This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ca_international_mig_2018 = px.line(california, x = 'Area_Name', y='INTERNATIONAL_MIG_2018', title="International Migration to Califonia 2018") | |
ca_international_mig_2018.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tx_international_mig_2018 = px.line(texas, x = 'Area_Name', y='INTERNATIONAL_MIG_2018', title="International Migration to Texas 2018") | |
tx_international_mig_2018.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trace0 = go.Scatter( | |
x = years_mig, | |
y = fl_international_mig, | |
mode = "lines", | |
name = "Florida" | |
) | |
trace1 = go.Scatter( | |
x = years_mig, | |
y = ny_international_mig, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fl = population_data.loc[population_data['Area_Name'] == 'Florida'] | |
fl_2010 = fl['INTERNATIONAL_MIG_2010'].tolist() | |
fl_2011 = fl['INTERNATIONAL_MIG_2011'].tolist() | |
fl_2012 = fl['INTERNATIONAL_MIG_2012'].tolist() | |
fl_2013 = fl['INTERNATIONAL_MIG_2013'].tolist() | |
fl_2014 = fl['INTERNATIONAL_MIG_2014'].tolist() | |
fl_2015 = fl['INTERNATIONAL_MIG_2015'].tolist() | |
fl_2016 = fl['INTERNATIONAL_MIG_2016'].tolist() | |
fl_2017 = fl['INTERNATIONAL_MIG_2017'].tolist() | |
fl_2018 = fl['INTERNATIONAL_MIG_2018'].tolist() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
X = fl_df.iloc[:, 0].values.reshape(-1, 1) # values converts it into a numpy array | |
Y = fl_df.iloc[:, 1].values.reshape(-1, 1) # -1 means that calculate the dimension of rows, but have 1 column | |
linear_regressor = LinearRegression() # create object for the class | |
linear_regressor.fit(X, Y) # perform linear regression | |
Y_pred = linear_regressor.predict(X) # make predictions | |
plt.scatter(X, Y) | |
plt.plot(X, Y_pred, color='red') | |
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
florida['text'] = "International Migration 2018"+"\ | |
"+ florida["INTERNATIONAL_MIG_2018"].astype(str) + " " +"County:" +" \ | |
"+ florida["Area_Name"] | |
values = florida['INTERNATIONAL_MIG_2018'].tolist() | |
fips = florida['FIPS'].tolist() | |
endpts = list(np.mgrid[min(values):max(values):4j]) | |
colorscale = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = florida['FIPS'].tolist() | |
fips = [str(i) for i in x] | |
values = florida['INTERNATIONAL_MIG_2018'].tolist() | |
fig = ff.create_choropleth(fips=fips, values=values) | |
fig.layout.template = None | |
fig.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Read csv file and load to population data data frame | |
population_data = pd.read_csv(".../population_estimates.csv") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
population_data.head() |