简体   繁体   English

将数据帧存储在postgres中的一个单元格中

[英]Store a dataframe in one cell in postgres

I have a data.frame which contains the grouping logic of region for example: 我有一个data.frame ,其中包含区域的分组逻辑,例如:

data1 <- data.frame(
    Group = c(1, 2, 3), 
    Region = c("Southeast Med, Southeast Low, Southwest Low, Northeast Med", "Northeast High, East Med, Midwest Med High", "Midwest Low, California and HI, West High"),
    stringsAsFactors = F)

I want to store this information in one cell in postgres. 我想将这些信息存储在postgres的一个单元格中。 How can I do it? 我该怎么做?

I tried converting it into a list , but that doesn't work. 我尝试将其转换为list ,但这不起作用。 Other options I am considering is to serialize it. 我正在考虑的其他选项是序列化它。 I tried creating it into a vector/string, but I lose the grouping information. 我尝试将其创建为矢量/字符串,但我丢失了分组信息。 I need to post it such that when I extract it, I can re-use it to group the data with the given information. 我需要发布它,这样当我提取它时,我可以重新使用它来分组给定信息的数据。

More details, or flow of thought can be sourced in this question: R: Creating a new column using another dataframe 可以在此问题中获得更多详细信息或思想流: R:使用其他数据框创建新列

Essentially, I am trying to store information from training data, and want to be able to replicate the grouping when new data comes in from the stored information. 本质上,我试图存储来自训练数据的信息,并希望能够在新数据从存储的信息中进入时复制分组。 Happy to provide any more information that is needed, if I missed it. 如果我错过了,很高兴提供所需的更多信息。

我创建了数据框到json并推送它,这是有效的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM