set_dataset#

pharmpy.modeling.set_dataset(model, path_or_df, datatype=None)[source]#

Load the dataset given datainfo

Parameters:
  • model (Model) – Pharmpy model

  • path_or_df (str, Path, or pd.DataFrame) – Dataset path or dataframe

  • datatype (str) – Type of dataset (optional)

Returns:

Model – Pharmpy model with new dataset and updated datainfo

Example

>>> from pharmpy.modeling import load_example_model, load_dataset, unload_dataset, set_dataset
>>> model = load_example_model("pheno")
>>> model = unload_dataset(model)
>>> dataset_path = model.datainfo.path
>>> model.dataset is None
True
>>> model = set_dataset(model, dataset_path, datatype='nonmem')
>>> model.dataset
     ID   TIME   AMT  WGT  APGR    DV  FA1  FA2
0     1    0.0  25.0  1.4   7.0   0.0  1.0  1.0
1     1    2.0   0.0  1.4   7.0  17.3  0.0  0.0
2     1   12.5   3.5  1.4   7.0   0.0  1.0  1.0
3     1   24.5   3.5  1.4   7.0   0.0  1.0  1.0
4     1   37.0   3.5  1.4   7.0   0.0  1.0  1.0
..   ..    ...   ...  ...   ...   ...  ...  ...
739  59  108.3   3.0  1.1   6.0   0.0  1.0  1.0
740  59  120.5   3.0  1.1   6.0   0.0  1.0  1.0
741  59  132.3   3.0  1.1   6.0   0.0  1.0  1.0
742  59  144.8   3.0  1.1   6.0   0.0  1.0  1.0
743  59  146.8   0.0  1.1   6.0  40.2  0.0  0.0

[744 rows x 8 columns]