Skip to content

Commit

Permalink
Merge branch 'main' into revisit_pow_docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sorhawell authored Aug 8, 2023
2 parents e3cf9a1 + 5be67e8 commit 3b2fff5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 3 additions & 3 deletions R/dataframe__frame.R
Original file line number Diff line number Diff line change
Expand Up @@ -1465,12 +1465,12 @@ DataFrame_describe = function(percentiles = c(.25, .75)) {

# compute aggregates
df_aggs = do.call(self$select, largs)
e_col_row_names = pl$lit(df_aggs$columns)$str$split(":")
e_col_row_names = pl$lit(df_aggs$columns)$str$splitn(":", 2)

# pivotize
df_pivot = pl$select(
e_col_row_names$arr$first()$alias("rowname"),
e_col_row_names$arr$last()$alias("colname"),
e_col_row_names$struct$field("field_0")$alias("rowname"),
e_col_row_names$struct$field("field_1")$alias("colname"),
pl$lit(unlist(as.data.frame(df_aggs)))$alias("value")
)$pivot(
values = "value", index = "rowname", columns = "colname"
Expand Down
11 changes: 9 additions & 2 deletions tests/testthat/test-dataframe.R
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,13 @@ test_that("describe", {
pl$DataFrame(mtcars)$describe(perc = numeric())$to_list(),
pl$DataFrame(mtcars)$describe(perc = NULL)$to_list()
)

# names using internal separator ":" in column names, should also just work.
df = pl$DataFrame("foo:bar:jazz" = 1, pl$Series(2, name = ""), "foobar" = 3)
expect_identical(
df$describe()$columns,
c("describe", df$columns)
)
})

test_that("glimpse", {
Expand Down Expand Up @@ -1019,8 +1026,8 @@ test_that("explode", {
)
)
})

test_that("with_row_count", {
df = pl$DataFrame(mtcars)
expect_identical(df$with_row_count("idx", 42)$select(pl$col("idx"))$to_data_frame()$idx, as.double(42:(41+nrow(mtcars))))
expect_identical(df$with_row_count("idx", 42)$select(pl$col("idx"))$to_data_frame()$idx, as.double(42:(41 + nrow(mtcars))))
})

0 comments on commit 3b2fff5

Please sign in to comment.