Skip to content

Commit

Permalink
Added flags method to DataFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed May 22, 2024
1 parent d1213c1 commit 04ce1cd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Updated Polars to 0.40.0
- Added `date_ranges` method to `Polars`
- Added `flags` method to `DataFrame`
- Added support for keyword arguments to `agg` methods
- Aliased `apply` to `map_rows` for `DataFrame`
- Changed default `name` for `with_row_index` from `row_nr` to `index`
Expand Down
7 changes: 7 additions & 0 deletions lib/polars/data_frame.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ def dtypes
_df.dtypes
end

# Get flags that are set on the columns of this DataFrame.
#
# @return [Hash]
def flags
self.columns.to_h { |name| [name, self[name].flags] }
end

# Get the schema.
#
# @return [Hash]
Expand Down
5 changes: 5 additions & 0 deletions test/data_frame_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ def test_dtypes
assert_equal [Polars::Int64, Polars::String], df.dtypes
end

def test_flags
df = Polars::DataFrame.new({"a" => [1, 2, 3], "b" => ["one", "two", "three"]})
assert df.flags
end

def test_schema
df = Polars::DataFrame.new({"a" => [1, 2, 3], "b" => ["one", "two", "three"]})
expected = {"a" => Polars::Int64, "b" => Polars::String}
Expand Down

0 comments on commit 04ce1cd

Please sign in to comment.