benhuff / random_geospatial

0 stars 0 forks source link

OLS #2

Open benhuff opened 1 year ago

benhuff commented 1 year ago
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import statsmodels.api as sm

X = sm.add_constant(merge['avg_rad'])
model = sm.OLS(merge['_mean'],X)
results = model.fit()
plt.scatter(merge['avg_rad'],merge['_mean'],alpha=0.3, marker='o')
y_predict = results.params[0] + results.params[1]*merge['avg_rad']
plt.plot(merge['avg_rad'],y_predict, linewidth=3)
plt.xlabel('avg_rad')
plt.ylabel('_mean')
plt.title('OLS Regression')

print(results.summary())
benhuff commented 1 year ago

plot a geodataframe with a datetime column as a playable gif

from bokeh.themes import built_in_themes
print(built_in_themes)
hv.renderer('bokeh').theme = 'dark_minimal'

geodataframe.hvplot.polygons(
    geo=True, 
    tools=['hover'], 
    width=800, 
    height=600, 
    line_color='None',
    color='YOUR_VALUE', 
    clim=(0, MAX_VALUE),
    colorbar=False, 
    xaxis=None, 
    yaxis=None, 
    groupby=['DATETIME'], 
    widget_type='scrubber', 
    widget_location='bottom'
)
benhuff commented 1 year ago

from stack overflow

mask = (df['date'] > '2000-6-1') & (df['date'] <= '2000-6-10')
print(df.loc[mask])