This file contains hidden or 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
import branca | |
# Create the map object | |
m = folium.Map(location=[48, -102], zoom_start=3) | |
# Create the colomap styles | |
colormap = branca.colormap.LinearColormap( | |
vmin=us_data_gdf["Total_Pop_2021"].quantile(0.0), | |
vmax=us_data_gdf["Total_Pop_2021"].quantile(1), | |
colors=["red", "orange", "lightblue", "green", "darkgreen"], |
This file contains hidden or 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
m = folium.Map(location=[48, -102], zoom_start=3) | |
folium.Choropleth( | |
geo_data=us_data_gdf, | |
name="choropleth", | |
data=us_data_gdf, | |
columns= ["GEOID","Total_Pop_2021"], | |
key_on="feature.properties.GEOID", | |
fill_color="YlGn", | |
fill_opacity=0.7, |
This file contains hidden or 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
m = folium.Map(location=[48, -102], zoom_start=3) | |
folium.Choropleth( | |
geo_data=usmap_gdf, | |
name="choropleth", | |
data=all_states_census_df, | |
columns= ["state_str","Total_Pop_2021"], | |
key_on="feature.id", | |
fill_color="YlGn", | |
fill_opacity=0.7, |
This file contains hidden or 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
m = folium.Map(location=[48, -102], zoom_start=3) | |
folium.Choropleth( | |
geo_data=usmap_json_with_id, | |
name="choropleth", | |
data=all_states_census_df, | |
columns=["state_str", "Total_Pop_2021"], | |
key_on="feature.id", | |
fill_color="YlGn", | |
fill_opacity=0.7, |
This file contains hidden or 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
# Import the folium library (only shown here once) | |
import folium | |
m = folium.Map(location=[48, -102], zoom_start=3) | |
folium.Choropleth( | |
geo_data=usmap_json_no_id, | |
name="choropleth", | |
data=all_states_census_df, | |
columns=["state", "Total_Pop_2021"], |
This file contains hidden or 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
# Create transformation columns of the adjusted close price | |
# Calculate the log of the adjusted close prices | |
inx_df['adj_close_log'] = np.log(inx_df['adj_close']) | |
# Calculate the square root of the adjusted close prices | |
inx_df['adj_close_sqrt'] = np.sqrt(inx_df['adj_close']) | |
# Calculate the cubed root of the adjusted close prices | |
inx_df['adj_close_cbrt'] = np.cbrt(inx_df['adj_close']) |
This file contains hidden or 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
# Plotly Growth Rate Chart For The Campbell Soup Company | |
# Calculate Growth Rate | |
cpb['growth_rate'] = cpb['Adj Close'].pct_change() | |
s_and_p['growth_rate'] = s_and_p['Adj Close'].pct_change() | |
fig = go.Figure() | |
# You can add multiple traces, in this case financial securities | |
fig.add_trace(go.Scatter(x=cpb.Date, y=cpb['growth_rate'], |
This file contains hidden or 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
# A Plotly OHLC Chart With A Rangeslider | |
# This code is adapted from the Plotly site | |
# Source: https://plot.ly/python/ohlc-charts/ | |
# Import the necessary libraries | |
import pandas as pd | |
import numpy as np | |
# The section of the Plotly library needed | |
import plotly.graph_objects as go |
This file contains hidden or 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
# This code was adapted from Harrison Kinsley's tutorial | |
# Source: https://pythonprogramming.net/candlestick-ohlc-graph-matplotlib-tutorial/ | |
# Import the necessary libraries | |
import pandas as pd | |
import numpy as np | |
from matplotlib import pyplot as plt | |
import matplotlib.dates as mdates | |
import matplotlib.ticker as mticker |
This file contains hidden or 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
# The code to generate a 3-D plot of Seinfeld and Curb Your Enthusiasm | |
# scripts with dimensions identified with Principal Component Analysis | |
import matplotlib.pyplot as plt | |
seinfeld_3d = transformed_data_3d[:num_seinfeld] | |
s3_x = [i[0] for i in seinfeld_3d] | |
s3_y = [i[1] for i in seinfeld_3d] | |
s3_z = [i[2] for i in seinfeld_3d] |
NewerOlder