@@ -834,27 +834,27 @@ def stack(
834
834
835
835
In [1]: import arviz as az
836
836
...: datadict = {
837
- "a": np.random.randn(100),
838
- "b": np.random.randn(1, 100, 10),
839
- "c": np.random.randn(1, 100, 3, 4),
840
- }
837
+ ...: "a": np.random.randn(100),
838
+ ...: "b": np.random.randn(1, 100, 10),
839
+ ...: "c": np.random.randn(1, 100, 3, 4),
840
+ ...: }
841
841
...: coords = {
842
- "c1": np.arange(3),
843
- "c99": np.arange(4),
844
- "b1": np.arange(10),
845
- }
842
+ ...: "c1": np.arange(3),
843
+ ...: "c99": np.arange(4),
844
+ ...: "b1": np.arange(10),
845
+ ...: }
846
846
...: dims = {"c": ["c1", "c99"], "b": ["b1"]}
847
847
...: idata = az.from_dict(
848
848
...: posterior=datadict, posterior_predictive=datadict, coords=coords, dims=dims
849
849
...: )
850
- ...: idata
850
+ ...: idata.posterior
851
851
852
852
In order to stack two dimensions ``c1`` and ``c99`` to ``z``, we can use:
853
853
854
854
.. ipython::
855
855
856
856
In [1]: idata.stack(z=["c1", "c99"], inplace=True)
857
- ...: idata
857
+ ...: idata.posterior
858
858
859
859
See Also
860
860
--------
@@ -919,28 +919,28 @@ def unstack(self, dim=None, groups=None, filter_groups=None, inplace=False):
919
919
920
920
In [1]: import arviz as az
921
921
...: datadict = {
922
- "a": np.random.randn(100),
923
- "b": np.random.randn(1, 100, 10),
924
- "c": np.random.randn(1, 100, 3, 4),
925
- }
922
+ ...: "a": np.random.randn(100),
923
+ ...: "b": np.random.randn(1, 100, 10),
924
+ ...: "c": np.random.randn(1, 100, 3, 4),
925
+ ...: }
926
926
...: coords = {
927
- "c1": np.arange(3),
928
- "c99": np.arange(4),
929
- "b1": np.arange(10),
930
- }
927
+ ...: "c1": np.arange(3),
928
+ ...: "c99": np.arange(4),
929
+ ...: "b1": np.arange(10),
930
+ ...: }
931
931
...: dims = {"c": ["c1", "c99"], "b": ["b1"]}
932
- ...: dataset = from_dict(
932
+ ...: idata = az. from_dict(
933
933
...: posterior=datadict, posterior_predictive=datadict, coords=coords, dims=dims
934
934
...: )
935
- ...: dataset .stack(z=["c1", "c99"], inplace=True)
936
- ...: dataset
935
+ ...: idata .stack(z=["c1", "c99"], inplace=True)
936
+ ...: idata
937
937
938
938
In order to unstack the dimension ``z``, we use:
939
939
940
940
.. ipython::
941
941
942
- In [1]: dataset .unstack(inplace=True)
943
- ...: dataset
942
+ In [1]: idata .unstack(inplace=True)
943
+ ...: idata
944
944
945
945
See Also
946
946
--------
@@ -1078,16 +1078,16 @@ def rename_vars(self, name_dict=None, groups=None, filter_groups=None, inplace=F
1078
1078
1079
1079
In [1]: import arviz as az
1080
1080
...: idata = az.load_arviz_data("rugby")
1081
- ...: print(list(idata.posterior.data_vars)
1082
- ...: print(list(idata.prior.data_vars)
1081
+ ...: print(list(idata.posterior.data_vars))
1082
+ ...: print(list(idata.prior.data_vars))
1083
1083
1084
1084
In order to rename the data variables, we use:
1085
1085
1086
1086
.. ipython::
1087
1087
1088
1088
In [1]: idata.rename_vars({"home": "home_new"}, inplace=True)
1089
- ...: print(list(idata.posterior.data_vars)
1090
- ...: print(list(idata.prior.data_vars)
1089
+ ...: print(list(idata.posterior.data_vars))
1090
+ ...: print(list(idata.prior.data_vars))
1091
1091
1092
1092
See Also
1093
1093
--------
@@ -1151,16 +1151,16 @@ def rename_dims(self, name_dict=None, groups=None, filter_groups=None, inplace=F
1151
1151
1152
1152
In [1]: import arviz as az
1153
1153
...: idata = az.load_arviz_data("rugby")
1154
- ...: print(list(idata.posterior.dims)
1155
- ...: print(list(idata.prior.dims)
1154
+ ...: print(list(idata.posterior.dims))
1155
+ ...: print(list(idata.prior.dims))
1156
1156
1157
1157
In order to rename the dimensions, we use:
1158
1158
1159
1159
.. ipython::
1160
1160
1161
1161
In [1]: idata.rename_dims({"team": "team_new"}, inplace=True)
1162
- ...: print(list(idata.posterior.dims)
1163
- ...: print(list(idata.prior.dims)
1162
+ ...: print(list(idata.posterior.dims))
1163
+ ...: print(list(idata.prior.dims))
1164
1164
1165
1165
See Also
1166
1166
--------
0 commit comments