mirror of
https://github.com/nushell/nushell.git
synced 2024-12-23 07:30:13 +01:00
b67b6f7fc5
# Description Today the only way to extract date parts from a dfr series is the dfr get-* set of commands. These create a new dataframe with just the datepart in it, which is almost entirely useless. As far as I can tell there's no way to append it as a series in the original dataframe. In discussion with fdncred on Discord we decided the best route was to add an expression for modifying columns created in dfr with-column. These are the way you manipulate series within a data frame. I'd like feedback on this approach - I think it's a fair way to handle things. An example to test it would be: ```[[ record_time]; [ (date now)]] | dfr into-df | dfr with-column [ ((dfr col record_time) | dfr datepart nanosecond | dfr as "ns" ), (dfr col record_time | dfr datepart second | dfr as "s"), (dfr col record_time | dfr datepart minute | dfr as "m"), (dfr col record_time | dfr datepart hour | dfr as "h") ]``` I'm also proposing we deprecate the dfr get-* commands. I've not been able to figure out any meaningful way they could ever be useful, and this approach makes more sense by attaching the extracted date part to the row in the original dataframe as a new column. <!-- Thank you for improving Nushell. Please, check our [contributing guide](../CONTRIBUTING.md) and talk to the core team before making major changes. Description of your pull request goes here. **Provide examples and/or screenshots** if your changes affect the user experience. --> # User-Facing Changes add in dfr datepart as an expression <!-- List of all changes that impact the user experience here. This helps us keep track of breaking changes. --> # Tests + Formatting Need to add some better assertive tests. I'm also not sure how to properly write the test_dataframe at the bottom, but will revisit as part of this PR. Wanted to get feedback early. <!-- Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect -A clippy::result_large_err` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass - `cargo run -- crates/nu-std/tests/run.nu` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` --> # After Submitting <!-- If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. --> --------- Co-authored-by: Robert Waugh <robert@waugh.io> |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
LICENSE |