Raghav Vashisht
Raghav Vashisht

Reputation: 81

How to change measure to hierarchy in atoti?

I have a categorical data (region code) with high ordinal value.

enter image description here

When I load this dataframe in atoti datastore it is being read as a measure but the data type is an object. enter image description here

Hence, ideally it should be a hierarchy.

How can I change a measure to an hierarchy in atoti?

Upvotes: 3

Views: 568

Answers (2)

Fabich
Fabich

Reputation: 3069

Disclaimer: I am a developer at atoti


When I load this dataframe in atoti datastore it is being read as a measure

Loading data into a datastore does not create any measure. It is the cube that you create on this store that creates measures and hierarchies automatically based on the types (because you are in auto mode by default).

ideally it should be a hierarchy.

Nothing prevents you from creating additional hierarchies and measures. For instance you can create a new hierarchy on any store column like that:

cube.hierarchies["Region Code"] =  [ store["Region_Code"] ]

You can also choose at the store creation which columns must be used as a hierarchy by specifying the hierarchized_columns arguments.

store = session.read_pandas(... hierarchized_columns=["Gender", "Age", "Region_Code"])

You can read more about this parameter in the read_pandas documentation for instance.

Also note that you don't have to "choose" between making a column a hierarchy or a measure, the same column can be used for both.

Upvotes: 3

Raghav Vashisht
Raghav Vashisht

Reputation: 81

Disclaimer: I work at atoti.

One workaround I figured to load the variable as a string an it will be treated a hierarchy.

   customer_store = session.read_pandas(
        master_data2,
        store_name="customer_store",types = {'Region_Code' : tt.types.STRING}
    )
    customer_store.head()

Upvotes: 0

Related Questions