diff --git a/crates/polars-core/src/frame/mod.rs b/crates/polars-core/src/frame/mod.rs index 0f9e0c345c30..a3bfddd89c46 100644 --- a/crates/polars-core/src/frame/mod.rs +++ b/crates/polars-core/src/frame/mod.rs @@ -1666,7 +1666,7 @@ impl DataFrame { /// ``` /// # use polars_core::prelude::*; /// fn example(df: &DataFrame) -> PolarsResult { - /// let mask = df.column("sepal.width")?.is_not_null(); + /// let mask = df.column("sepal_width")?.is_not_null(); /// df.filter(&mask) /// } /// ``` @@ -1884,8 +1884,8 @@ impl DataFrame { /// Sort by a single column with default options: /// ``` /// # use polars_core::prelude::*; - /// fn sort_by_a(df: &DataFrame) -> PolarsResult { - /// df.sort(["a"], Default::default()) + /// fn sort_by_sepal_width(df: &DataFrame) -> PolarsResult { + /// df.sort(["sepal_width"], Default::default()) /// } /// ``` /// Sort by a single column with specific order: @@ -1893,7 +1893,7 @@ impl DataFrame { /// # use polars_core::prelude::*; /// fn sort_with_specific_order(df: &DataFrame, descending: bool) -> PolarsResult { /// df.sort( - /// ["a"], + /// ["sepal_width"], /// SortMultipleOptions::new() /// .with_order_descending(descending) /// ) @@ -1904,7 +1904,7 @@ impl DataFrame { /// # use polars_core::prelude::*; /// fn sort_by_multiple_columns_with_specific_order(df: &DataFrame) -> PolarsResult { /// df.sort( - /// &["a", "b"], + /// &["sepal_width", "sepal_length"], /// SortMultipleOptions::new() /// .with_order_descendings([false, true]) /// ) diff --git a/crates/polars-lazy/src/frame/mod.rs b/crates/polars-lazy/src/frame/mod.rs index d0571432f75f..39ef52c3b820 100644 --- a/crates/polars-lazy/src/frame/mod.rs +++ b/crates/polars-lazy/src/frame/mod.rs @@ -259,12 +259,12 @@ impl LazyFrame { /// /// # Example /// - /// Sort DataFrame by 'sepal.width' column: + /// Sort DataFrame by 'sepal_width' column: /// ```rust /// # use polars_core::prelude::*; /// # use polars_lazy::prelude::*; /// fn sort_by_a(df: DataFrame) -> LazyFrame { - /// df.lazy().sort(["a"], Default::default()) + /// df.lazy().sort(["sepal_width"], Default::default()) /// } /// ``` /// Sort by a single column with specific order: @@ -273,7 +273,7 @@ impl LazyFrame { /// # use polars_lazy::prelude::*; /// fn sort_with_specific_order(df: DataFrame, descending: bool) -> LazyFrame { /// df.lazy().sort( - /// ["a"], + /// ["sepal_width"], /// SortMultipleOptions::new() /// .with_order_descending(descending) /// ) @@ -285,7 +285,7 @@ impl LazyFrame { /// # use polars_lazy::prelude::*; /// fn sort_by_multiple_columns_with_specific_order(df: DataFrame) -> LazyFrame { /// df.lazy().sort( - /// &["a", "b"], + /// &["sepal_width", "sepal_length"], /// SortMultipleOptions::new() /// .with_order_descendings([false, true]) /// ) @@ -317,10 +317,10 @@ impl LazyFrame { /// use polars_core::prelude::*; /// use polars_lazy::prelude::*; /// - /// /// Sort DataFrame by 'sepal.width' column + /// /// Sort DataFrame by 'sepal_width' column /// fn example(df: DataFrame) -> LazyFrame { /// df.lazy() - /// .sort_by_exprs(vec![col("sepal.width")], Default::default()) + /// .sort_by_exprs(vec![col("sepal_width")], Default::default()) /// } /// ``` pub fn sort_by_exprs>( @@ -830,8 +830,8 @@ impl LazyFrame { /// /// fn example(df: DataFrame) -> LazyFrame { /// df.lazy() - /// .filter(col("sepal.width").is_not_null()) - /// .select(&[col("sepal.width"), col("sepal.length")]) + /// .filter(col("sepal_width").is_not_null()) + /// .select(&[col("sepal_width"), col("sepal_length")]) /// } /// ``` pub fn filter(self, predicate: Expr) -> Self { @@ -1263,7 +1263,7 @@ impl LazyFrame { /// fn add_column(df: DataFrame) -> LazyFrame { /// df.lazy() /// .with_column( - /// when(col("sepal.length").lt(lit(5.0))) + /// when(col("sepal_length").lt(lit(5.0))) /// .then(lit(10)) /// .otherwise(lit(1)) /// .alias("new_column_name"), diff --git a/crates/polars-lazy/src/tests/arity.rs b/crates/polars-lazy/src/tests/arity.rs index 93d3fae74ea2..7ed5cc6e4a7b 100644 --- a/crates/polars-lazy/src/tests/arity.rs +++ b/crates/polars-lazy/src/tests/arity.rs @@ -66,7 +66,7 @@ fn test_lazy_ternary() { let df = get_df() .lazy() .with_column( - when(col("sepal.length").lt(lit(5.0))) + when(col("sepal_length").lt(lit(5.0))) .then(lit(10)) .otherwise(lit(1)) .alias("new"), diff --git a/crates/polars-lazy/src/tests/logical.rs b/crates/polars-lazy/src/tests/logical.rs index 93babe7f2788..3c905bebf368 100644 --- a/crates/polars-lazy/src/tests/logical.rs +++ b/crates/polars-lazy/src/tests/logical.rs @@ -64,7 +64,7 @@ fn test_lazy_arithmetic() { let df = get_df(); let lf = df .lazy() - .select(&[((col("sepal.width") * lit(100)).alias("super_wide"))]) + .select(&[((col("sepal_width") * lit(100)).alias("super_wide"))]) .sort(["super_wide"], SortMultipleOptions::default()); print_plans(&lf); @@ -83,7 +83,7 @@ fn test_lazy_logical_plan_filter_and_alias_combined() { let df = get_df(); let lf = df .lazy() - .filter(col("sepal.width").lt(lit(3.5))) + .filter(col("sepal_width").lt(lit(3.5))) .select(&[col("variety").alias("foo")]); print_plans(&lf); @@ -105,9 +105,9 @@ fn test_lazy_logical_plan_schema() { let lp = df .lazy() .group_by([col("variety")]) - .agg([col("sepal.width").min()]) + .agg([col("sepal_width").min()]) .logical_plan; - assert!(lp.schema().unwrap().get("sepal.width").is_some()); + assert!(lp.schema().unwrap().get("sepal_width").is_some()); } #[test] diff --git a/crates/polars-lazy/src/tests/mod.rs b/crates/polars-lazy/src/tests/mod.rs index 5040843354ed..c598dddb9233 100644 --- a/crates/polars-lazy/src/tests/mod.rs +++ b/crates/polars-lazy/src/tests/mod.rs @@ -167,7 +167,7 @@ pub(crate) fn fruits_cars() -> DataFrame { pub(crate) fn get_df() -> DataFrame { let s = r#" -"sepal.length","sepal.width","petal.length","petal.width","variety" +"sepal_length","sepal_width","petal_length","petal_width","variety" 5.1,3.5,1.4,.2,"Setosa" 4.9,3,1.4,.2,"Setosa" 4.7,3.2,1.3,.2,"Setosa" diff --git a/crates/polars-lazy/src/tests/queries.rs b/crates/polars-lazy/src/tests/queries.rs index 9ededd33211c..49b275047097 100644 --- a/crates/polars-lazy/src/tests/queries.rs +++ b/crates/polars-lazy/src/tests/queries.rs @@ -20,17 +20,17 @@ fn test_lazy_exec() { let _new = df .clone() .lazy() - .select([col("sepal.width"), col("variety")]) - .sort(["sepal.width"], Default::default()) + .select([col("sepal_width"), col("variety")]) + .sort(["sepal_width"], Default::default()) .collect(); let new = df .lazy() - .filter(not(col("sepal.width").lt(lit(3.5)))) + .filter(not(col("sepal_width").lt(lit(3.5)))) .collect() .unwrap(); - let check = new.column("sepal.width").unwrap().f64().unwrap().gt(3.4); + let check = new.column("sepal_width").unwrap().f64().unwrap().gt(3.4); assert!(check.all()) } @@ -39,10 +39,10 @@ fn test_lazy_alias() { let df = get_df(); let new = df .lazy() - .select([col("sepal.width").alias("petals"), col("sepal.width")]) + .select([col("sepal_width").alias("petals"), col("sepal_width")]) .collect() .unwrap(); - assert_eq!(new.get_column_names(), &["petals", "sepal.width"]); + assert_eq!(new.get_column_names(), &["petals", "sepal_width"]); } #[test] @@ -50,16 +50,16 @@ fn test_lazy_melt() { let df = get_df(); let args = MeltArgs { - id_vars: vec!["petal.width".into(), "petal.length".into()], - value_vars: vec!["sepal.length".into(), "sepal.width".into()], + id_vars: vec!["petal_width".into(), "petal_length".into()], + value_vars: vec!["sepal_length".into(), "sepal_width".into()], ..Default::default() }; let out = df .lazy() .melt(args) - .filter(col("variable").eq(lit("sepal.length"))) - .select([col("variable"), col("petal.width"), col("value")]) + .filter(col("variable").eq(lit("sepal_length"))) + .select([col("variable"), col("petal_width"), col("value")]) .collect() .unwrap(); assert_eq!(out.shape(), (7, 3)); @@ -87,11 +87,11 @@ fn test_lazy_udf() { let df = get_df(); let new = df .lazy() - .select([col("sepal.width").map(|s| Ok(Some(s * 200.0)), GetOutput::same_type())]) + .select([col("sepal_width").map(|s| Ok(Some(s * 200.0)), GetOutput::same_type())]) .collect() .unwrap(); assert_eq!( - new.column("sepal.width").unwrap().f64().unwrap().get(0), + new.column("sepal_width").unwrap().f64().unwrap().get(0), Some(700.0) ); } @@ -102,7 +102,7 @@ fn test_lazy_is_null() { let new = df .clone() .lazy() - .filter(col("sepal.width").is_null()) + .filter(col("sepal_width").is_null()) .collect() .unwrap(); @@ -111,7 +111,7 @@ fn test_lazy_is_null() { let new = df .clone() .lazy() - .filter(col("sepal.width").is_not_null()) + .filter(col("sepal_width").is_not_null()) .collect() .unwrap(); assert_eq!(new.height(), df.height()); @@ -119,7 +119,7 @@ fn test_lazy_is_null() { let new = df .lazy() .group_by([col("variety")]) - .agg([col("sepal.width").min()]) + .agg([col("sepal_width").min()]) .collect() .unwrap(); @@ -134,8 +134,8 @@ fn test_lazy_pushdown_through_agg() { .lazy() .group_by([col("variety")]) .agg([ - col("sepal.length").min(), - col("petal.length").min().alias("foo"), + col("sepal_length").min(), + col("petal_length").min().alias("foo"), ]) .select([col("foo")]) // second selection is to test if optimizer can handle that @@ -153,7 +153,7 @@ fn test_lazy_shift() { let df = get_df(); let new = df .lazy() - .select([col("sepal.width").alias("foo").shift(lit(2))]) + .select([col("sepal_width").alias("foo").shift(lit(2))]) .collect() .unwrap(); assert_eq!(new.column("foo").unwrap().f64().unwrap().get(0), None); @@ -205,18 +205,18 @@ fn test_lazy_ternary_and_predicates() { let ldf = df .lazy() .with_column( - when(col("sepal.length").lt(lit(5.0))) + when(col("sepal_length").lt(lit(5.0))) .then( lit(3), // is another type on purpose to check type coercion ) - .otherwise(col("sepal.width")) + .otherwise(col("sepal_width")) .alias("foo"), ) .filter(col("foo").gt(lit(3.0))); let new = ldf.collect().unwrap(); - let length = new.column("sepal.length").unwrap(); - assert_eq!(length, &Series::new("sepal.length", &[5.1f64, 5.0, 5.4])); + let length = new.column("sepal_length").unwrap(); + assert_eq!(length, &Series::new("sepal_length", &[5.1f64, 5.0, 5.4])); assert_eq!(new.shape(), (3, 6)); } @@ -550,7 +550,7 @@ fn test_simplify_expr() { let plan = df .lazy() - .select(&[lit(1.0f32) + lit(1.0f32) + col("sepal.width")]) + .select(&[lit(1.0f32) + lit(1.0f32) + col("sepal_width")]) .logical_plan; let mut expr_arena = Arena::new(); diff --git a/crates/polars/src/docs/eager.rs b/crates/polars/src/docs/eager.rs index a4ad82b91eee..7ea159c2ee8e 100644 --- a/crates/polars/src/docs/eager.rs +++ b/crates/polars/src/docs/eager.rs @@ -323,10 +323,10 @@ //! //! # fn example(df: &DataFrame) -> PolarsResult<()> { //! // create a mask to filter out null values -//! let mask = df.column("sepal.width")?.is_not_null(); +//! let mask = df.column("sepal_width")?.is_not_null(); //! //! // select column -//! let s = df.column("sepal.length")?; +//! let s = df.column("sepal_length")?; //! //! // apply filter on a Series //! let filtered_series = s.filter(&mask); diff --git a/crates/polars/tests/it/io/csv.rs b/crates/polars/tests/it/io/csv.rs index acb7ac544ca9..b07411709558 100644 --- a/crates/polars/tests/it/io/csv.rs +++ b/crates/polars/tests/it/io/csv.rs @@ -138,7 +138,7 @@ fn test_read_csv_file() { #[test] fn test_parser() -> PolarsResult<()> { let s = r#" - "sepal.length","sepal.width","petal.length","petal.width","variety" + "sepal_length","sepal_width","petal_length","petal_width","variety" 5.1,3.5,1.4,.2,"Setosa" 4.9,3,1.4,.2,"Setosa" 4.7,3.2,1.3,.2,"Setosa" @@ -157,7 +157,7 @@ fn test_parser() -> PolarsResult<()> { .unwrap(); let s = r#" - "sepal.length","sepal.width","petal.length","petal.width","variety" + "sepal_length","sepal_width","petal_length","petal_width","variety" 5.1,3.5,1.4,.2,"Setosa" 5.1,3.5,1.4,.2,"Setosa" "#; @@ -173,7 +173,7 @@ fn test_parser() -> PolarsResult<()> { .finish() .unwrap(); - let s = r#""sepal.length","sepal.width","petal.length","petal.width","variety" + let s = r#""sepal_length","sepal_width","petal_length","petal_width","variety" 5.1,3.5,1.4,.2,"Setosa" 4.9,3,1.4,.2,"Setosa" 4.7,3.2,1.3,.2,"Setosa" @@ -194,8 +194,8 @@ fn test_parser() -> PolarsResult<()> { assert_eq!(col.get(0)?, AnyValue::String("Setosa")); assert_eq!(col.get(2)?, AnyValue::String("Setosa")); - assert_eq!("sepal.length", df.get_columns()[0].name()); - assert_eq!(1, df.column("sepal.length").unwrap().chunks().len()); + assert_eq!("sepal_length", df.get_columns()[0].name()); + assert_eq!(1, df.column("sepal_length").unwrap().chunks().len()); assert_eq!(df.height(), 7); // test windows line endings @@ -427,7 +427,7 @@ id090,id048,id0000067778,24,2,51862,4,9, #[test] fn test_new_line_escape() { - let s = r#""sepal.length","sepal.width","petal.length","petal.width","variety" + let s = r#""sepal_length","sepal_width","petal_length","petal_width","variety" 5.1,3.5,1.4,.2,"Setosa texts after new line character" 4.9,3,1.4,.2,"Setosa"