# Pandas
nums = sample(range(1, 20), 9)
PD = pd.DataFrame({
'A': nums,
'B': range(1, 10),
'C': ["b"]*3 + ["a"]*3 + ["c"]*3,
'D': ['startswith_this', np.NaN, 'c', 'd', 'e', np.NaN, 'this_endwith', 'k', 'z']
})
PD
## A B C D
## 0 19 1 b startswith_this
## 1 4 2 b NaN
## 2 2 3 b c
## 3 9 4 a d
## 4 11 5 a e
## 5 15 6 a NaN
## 6 16 7 c this_endwith
## 7 6 8 c k
## 8 12 9 c z
| # Pydatatable
PY_DT = dt.Frame({
'A': nums,
'B': range(1, 10),
'C': ["b"]*3 + ["a"]*3 + ["c"]*3,
'D': ['startswith_this', None, 'c', 'd', 'e', None, 'this_endwith', 'k', 'z']
})
PY_DT
## | A B C D
## | int32 int32 str32 str32
## -- + ----- ----- ----- ---------------
## 0 | 19 1 b startswith_this
## 1 | 4 2 b NA
## 2 | 2 3 b c
## 3 | 9 4 a d
## 4 | 11 5 a e
## 5 | 15 6 a NA
## 6 | 16 7 c this_endwith
## 7 | 6 8 c k
## 8 | 12 9 c z
## [9 rows x 4 columns]
| # Dplyr
TB <- tibble(
A = py$nums,
B = 1:9,
C = rep(c("b", "a", "c"), each = 3),
D = c("startswith_this", NA_character_, "c", "d", "e", NA_character_, "this_endwith", "k", "z")
)
TB
## # A tibble: 9 × 4
## A B C D
## <int> <int> <chr> <chr>
## 1 19 1 b startswith_this
## 2 4 2 b <NA>
## 3 2 3 b c
## 4 9 4 a d
## 5 11 5 a e
## 6 15 6 a <NA>
## 7 16 7 c this_endwith
## 8 6 8 c k
## 9 12 9 c z
| # Data.table
R_DT <- data.table(
A = py$nums,
B = 1:9,
C = rep(c("b", "a", "c"), each = 3),
D = c("startswith_this", NA_character_, "c", "d", "e", NA_character_, "this_endwith", "k", "z")
)
R_DT
## A B C D
## 1: 19 1 b startswith_this
## 2: 4 2 b <NA>
## 3: 2 3 b c
## 4: 9 4 a d
## 5: 11 5 a e
## 6: 15 6 a <NA>
## 7: 16 7 c this_endwith
## 8: 6 8 c k
## 9: 12 9 c z
|