Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(rust): Fix some doc examples #9405

Merged
merged 3 commits into from
Jun 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions polars/src/docs/eager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@
//! temp.outer_join(&rain, ["days"], ["days"]);
//!
//! // join on multiple columns
//! temp.join(&rain, vec!["days", "other"], vec!["days", "other"], JoinType::Left, None);
//! temp.join(&rain, vec!["days", "other"], vec!["days", "other"], JoinArgs::new(JoinType::Left));
//!
//! # Ok(())
//! # }
Expand Down Expand Up @@ -435,9 +435,7 @@
//! )?;
//!
//! // groupby "foo" | pivot "bar" column | aggregate "N"
//! let pivoted = df.groupby(["foo"])?
//! .pivot(["bar"], ["N"])
//! .first();
//! let pivoted = pivot::pivot(&df, ["foo"], ["bar"], ["N"], false, Some(first()), None);
//!
//! // pivoted:
//! // +-----+------+------+------+------+------+
Expand Down Expand Up @@ -631,7 +629,7 @@
//! use polars::prelude::*;
//! use std::fs::File;
//!
//! # fn example(df: &mut DataFrame) -> PolarsResult<()> {
//! # fn example(df: &mut DataFrame) -> PolarsResult<u64> {
//! // create a file
//! let file = File::create("example.parquet").expect("could not create file");
//!
Expand Down
4 changes: 2 additions & 2 deletions polars/src/docs/lazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
//! let lf_a = df_a.clone().lazy();
//! let lf_b = df_b.clone().lazy();
//!
//! let joined = lf_a.join(lf_b, vec![col("a")], vec![col("foo")], JoinType::Outer).collect()?;
//! let joined = lf_a.join(lf_b, vec![col("a")], vec![col("foo")], JoinArgs::new(JoinType::Outer)).collect()?;
//! // joined:
//!
//! // ╭─────┬─────┬─────┬──────┬─────────╮
Expand Down Expand Up @@ -241,7 +241,7 @@
//! that you need to pass the values to an external function you do not control. The snippet below
//! shows how we use the `Struct` datatype to be able to apply a function over multiple inputs.
//!
//! ```
//! ```ignore
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't know how to fix this one - ignored for now.

//! use polars::prelude::*;
//! fn my_black_box_function(a: f32, b: f32) -> f32 {
//! // do something
Expand Down
2 changes: 1 addition & 1 deletion polars/src/docs/performance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
//!
//! df_a.try_apply("a", |s| s.categorical().cloned())?;
//! df_b.try_apply("b", |s| s.categorical().cloned())?;
//! df_a.join(&df_b, ["a"], ["b"], JoinType::Inner, None)
//! df_a.join(&df_b, ["a"], ["b"], JoinArgs::new(JoinType::Inner))
//! }
//! ```
//!
Expand Down
42 changes: 19 additions & 23 deletions polars/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//! .agg([
//! // expressions can be combined into powerful aggregations
//! col("foo")
//! .sort_by([col("ham").rank(Default::default())], [false])
//! .sort_by([col("ham").rank(Default::default(), None)], [false])
//! .last()
//! .alias("last_foo_ranked_by_ham"),
//! // every expression runs in parallel
Expand All @@ -31,7 +31,7 @@
//! .select([col("ham"), col("spam")]);
//!
//! let df = lf1
//! .join(lf2, [col("reverse")], [col("foo")], JoinType::Left)
//! .join(lf2, [col("reverse")], [col("foo")], JoinArgs::new(JoinType::Left))
//! // now we finally materialize the result.
//! .collect()?;
//! # Ok(())
Expand Down Expand Up @@ -325,28 +325,24 @@
//!
//! ## Config with ENV vars
//!
//! * `POLARS_FMT_TABLE_FORMATTING` -> define styling of tables using any of the following options (default = UTF8_FULL_CONDENSED):
//!
//! ASCII_FULL
//! ASCII_FULL_CONDENSED
//! ASCII_NO_BORDERS
//! ASCII_BORDERS_ONLY
//! ASCII_BORDERS_ONLY_CONDENSED
//! ASCII_HORIZONTAL_ONLY
//! ASCII_MARKDOWN
//! UTF8_FULL
//! UTF8_FULL_CONDENSED
//! UTF8_NO_BORDERS
//! UTF8_BORDERS_ONLY
//! UTF8_HORIZONTAL_ONLY
//! NOTHING
//!
//! These options are defined by comfy-table which provides examples for each at:
//! https://github.com/Nukesor/comfy-table/blob/main/src/style/presets.rs
//! * `POLARS_FMT_TABLE_FORMATTING` -> define styling of tables using any of the following options (default = UTF8_FULL_CONDENSED). These options are defined by comfy-table which provides examples for each at <https://github.com/Nukesor/comfy-table/blob/main/src/style/presets.rs>
//! * `ASCII_FULL`
//! * `ASCII_FULL_CONDENSED`
//! * `ASCII_NO_BORDERS`
//! * `ASCII_BORDERS_ONLY`
//! * `ASCII_BORDERS_ONLY_CONDENSED`
//! * `ASCII_HORIZONTAL_ONLY`
//! * `ASCII_MARKDOWN`
//! * `UTF8_FULL`
//! * `UTF8_FULL_CONDENSED`
//! * `UTF8_NO_BORDERS`
//! * `UTF8_BORDERS_ONLY`
//! * `UTF8_HORIZONTAL_ONLY`
//! * `NOTHING`
//! * `POLARS_FMT_TABLE_CELL_ALIGNMENT` -> define cell alignment using any of the following options (default = LEFT):
//! LEFT
//! CENTER
//! RIGHT
//! * `LEFT`
//! * `CENTER`
//! * `RIGHT`
//! * `POLARS_FMT_TABLE_DATAFRAME_SHAPE_BELOW` -> print shape information below the table.
//! * `POLARS_FMT_TABLE_HIDE_COLUMN_NAMES` -> hide table column names.
//! * `POLARS_FMT_TABLE_HIDE_COLUMN_DATA_TYPES` -> hide data types for columns.
Expand Down