10 SO 01-10

10.1 Test Data

R

df_r <- readr::read_rds('data/R_01_readr.rds')
str(df_r)
## 'data.frame':    4 obs. of  4 variables:
##  $ INT: int  1 2 3 4
##  $ NUM: num  0 1 2 3
##  $ CHR: chr  "a" "b" "c" "d"
##  $ LGL: logi  FALSE TRUE FALSE TRUE

Python

df_y = pyarrow.feather.read_feather('data/Y_01_pyarrow.feather')
df_y.info(memory_usage = False)
## <class 'pandas.core.frame.DataFrame'>
## RangeIndex: 4 entries, 0 to 3
## Data columns (total 4 columns):
##  #   Column  Non-Null Count  Dtype  
## ---  ------  --------------  -----  
##  0   INT     4 non-null      int64  
##  1   NUM     4 non-null      float64
##  2   CHR     4 non-null      object 
##  3   LGL     4 non-null      bool   
## dtypes: bool(1), float64(1), int64(1), object(1)

10.2 001-010

R

aa <- df_r
dput(aa)                                          #Write an Object to Console
## structure(list(INT = 1:4, NUM = c(0, 1, 2, 3), CHR = c("a", "b", 
## "c", "d"), LGL = c(FALSE, TRUE, FALSE, TRUE)), class = "data.frame", row.names = c(NA, 
## -4L))

Python

pp = {'x': (11, 22), 'y': [11, 22]}
assert(eval(repr(pp)) == pp)                      #May lose dtypes

Python

pp = df_y.copy()
assert(pd.DataFrame(pp.to_dict()).equals(pp))

pp.to_dict()                                      #May lose dtypes
## {'INT': {0: 1, 1: 2, 2: 3, 3: 4}, 'NUM': {0: 0.0, 1: 1.0, 2: 2.0, 3: 3.0}, 'CHR': {0: 'a', 1: 'b', 2: 'c', 3: 'd'}, 'LGL': {0: False, 1: True, 2: False, 3: True}}