[Question] how to set data range with `Dynamics()` and `Dynamics.from_data()`
shik-design opened this issue · 2 comments
shik-design commented
Checkbox
- I agree to follow code of conduct and to engage in discussion actively.
- I agree to create a new issue with the other templates if developers request.
Question
dyn_act = cs.Dynamics.from_data(model=cs.SIRModel, data=actual_df, name="None")
dyn_act.register().tail()
where will I run the above codes with date_range=("01Jan2022", "30Jun2022")
What tried
import covsirphy as cs
print(cs.__version__)
dyn_act = cs.Dynamics.from_data(model=cs.SIRModel, date_range=("01Jan2022", "30Jun2022"), data=actual_df, name="None")
dyn_act.register().tail()
### Additional Context
_No response_
lisphilar commented
We have two solutions.
- Subset
actual_df
withpandas.DatetimeIndex
dyn_act = cs.Dynamics.from_data(model=cs.SIRModel, data=actual_df["2022-01-01":"2022-06-30"], name=None)
dyn_act.register().tail()
- Initialize
Dynamics
instance without.from_data()
class method
dyn_act = cs.Dynamics(model=cs.SIRModel, date_range=("01Jan2022", "30Jun2022"), name=None)
dyn_act.register(data=actual_df).tail()
Note that Dynamics.from_data()
calls Dynamics(...)
and Dynamics.register(...)
, setting the min/max dates of actual_df
as the date range automaticallly.
covid19-sir/covsirphy/dynamics/dynamics.py
Lines 115 to 142 in dfbac35
shik-design commented
Thanks a lot