Skip to content

Preserve declared columns for empty row input - #1173

Open
mvanhorn wants to merge 1 commit into
elixir-explorer:mainfrom
mvanhorn:fix/1137-empty-dataframe-dtypes
Open

mvanhorn wants to merge 1 commit into
elixir-explorer:mainfrom
mvanhorn:fix/1137-empty-dataframe-dtypes

Conversation

@mvanhorn

Copy link
Copy Markdown

Why

Creating a dataframe from an empty row list drops every column declared in dtypes. Callers get a dataframe with zero rows and zero columns even when they supplied a schema.

The constructor passed the empty list through the general input path. With no rows to supply column names, that path had no columns to apply the declared dtypes to.

What changed

When the row list is empty and dtypes contains entries, the constructor creates a named empty series for each declared dtype using the corresponding series backend, then builds the dataframe from those series. A regression test checks column order, dtypes, and shape for eager and lazy dataframes. It also covers empty input without a schema and rejection of an invalid dtype.

Testing

repo_lint ran three times with no output or exit status shown. mix format --check-formatted ran with no output or exit status shown. cargo fmt --manifest-path=${{ matrix.manifest }} --all -- --check was listed with no output or exit status shown. cargo clippy --manifest-path=${{ matrix.manifest }} -- -Dwarnings was listed with no output or exit status shown. A run with the explorer change reverted gave no clear result, so no test is shown to catch this bug. The changed test test/explorer/data_frame_test.exs did not run here: no test runner for it was available.

Closes #1137

When the row list is empty and `dtypes` contains entries, the
constructor creates a named empty series for each declared dtype using
the corresponding series backend, then builds the dataframe from those
series. A regression test checks column order, dtypes, and shape for
eager and lazy dataframes. It also covers empty input without a schema
and rejection of an invalid dtype.

Fixes elixir-explorer#1137

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

Creating a dataframe from no data seems inconsistent

1 participant