Question: we need to prepare a DataFrame that counts the number of non - zero precipitation hours each day. This is done for you below when

we need to prepare a DataFrame that counts the number of non-zero precipitation hours each day. This is done for you below when creating `daily_counts`
daily_counts =(
df.groupby(pd.Grouper(key="dt", freq="D"))
.agg({
"precip": [lambda x: (x >0).sum(), "mean", "sum"],
"temp": ['min', 'max'],
})
.assign(month=lambda x: x.index.month)
).dropna()
daily_counts.columns =["n_precip_hours", "ave_hourly_precip", "daily_precip", "temp_min", "temp_max", "month"]
daily_counts.head()
Using this DataFrame and the statsmodels library, fit the appropriate GLM model to predict the number of hours with non-zero precipitation in a day
You shoud use as features, temp_min, temp_max, and a collection of indidcator variables for the month. In total you will have 14 features.
# count_model = smf.glm(
# ..., # CHANGE FORMULA
# daily_counts,
# family=... # CHANGE FAMILY
# )
# your code here
count_model_fit = count_model.fit()
count_model_fit.summary()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!