Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attributes are not saved #272

Open
OfekShilon opened this issue Jan 9, 2023 · 1 comment
Open

attributes are not saved #272

OfekShilon opened this issue Jan 9, 2023 · 1 comment

Comments

@OfekShilon
Copy link

Including row.names:

df <- data.frame(a=1:3,b=4:6)
rownames(df) <- c("row1","row2","row3")
df
#      a b
# row1 1 4
# row2 2 5
# row3 3 6
fst::write_fst(df,"~/tmp/df")
df2 <- fst::read_fst("~/tmp/df")
df2
#   a b
# 1 1 4
# 2 2 5
# 3 3 6

and class:

df <- data.table(a=1:3,b=4:6)
# [1] "data.table" "data.frame"
fst::write_fst(df,"~/tmp/df")
df2 <- fst::read_fst("~/tmp/df")
class(df2)
# [1] "data.frame"
@ben-schwen
Copy link

ben-schwen commented Jan 11, 2024

An "easy" way (avoid saving a list) to achieve this would be to first serialize the attributes in R via serialize(attributes(dt)) because then you only have to store a raw vector (which fst already supports) and later attributes(dt) = deserialize(attributesVec) them again in R.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants