问题描述
我在atoti有一家商店,我想在那里创建基于连续变量的存储桶。
这是商店的截图:
我正在尝试根据年龄创建存储桶。
我能想到的一个解决方案是,在原始数据框中创建一个新列,然后将其加入到现有存储中。
是否有更智能的方法可以在不返回原始数据框的情况下动态创建基于另一列的列?
解决方法
免责声明:我是atoti 的数据科学家。 好吧,您可以使用 read_pandas 读取一个新的数据帧并将其加入到现有的存储中。
这样的事情应该可以工作。
# age group buckets
age_groups_store = session.read_pandas(
pd.DataFrame(
data=[("0-30Y",i) for i in range(30)]
+ [("30Y - 40Y",i) for i in range(30,40)]
+ [("40Y - 50Y",i) for i in range(40,50)]
+ [("50Y+",i) for i in range(50,200)],columns=["age group","age"],),keys=["age"],store_name="Age Groups",)
customer_store.join(age_groups_store)