diff --git a/crates/polars-io/src/csv/buffer.rs b/crates/polars-io/src/csv/buffer.rs index faf216879192..54b145b81f21 100644 --- a/crates/polars-io/src/csv/buffer.rs +++ b/crates/polars-io/src/csv/buffer.rs @@ -486,7 +486,7 @@ pub(crate) fn init_buffers( schema: &Schema, quote_char: Option, encoding: CsvEncoding, - decimal_float: bool, + decimal_comma: bool, ) -> PolarsResult> { projection .iter() @@ -507,7 +507,7 @@ pub(crate) fn init_buffers( &DataType::UInt32 => Buffer::UInt32(PrimitiveChunkedBuilder::new(name, capacity)), &DataType::UInt64 => Buffer::UInt64(PrimitiveChunkedBuilder::new(name, capacity)), &DataType::Float32 => { - if decimal_float { + if decimal_comma { Buffer::DecimalFloat32( PrimitiveChunkedBuilder::new(name, capacity), Default::default(), @@ -517,7 +517,7 @@ pub(crate) fn init_buffers( } }, &DataType::Float64 => { - if decimal_float { + if decimal_comma { Buffer::DecimalFloat64( PrimitiveChunkedBuilder::new(name, capacity), Default::default(), @@ -825,7 +825,7 @@ impl Buffer { None, ), DecimalFloat32(buf, scratch) => { - prepare_decimal_float(bytes, scratch); + prepare_decimal_comma(bytes, scratch); as ParsedBuffer>::parse_bytes( buf, scratch, @@ -836,7 +836,7 @@ impl Buffer { ) }, DecimalFloat64(buf, scratch) => { - prepare_decimal_float(bytes, scratch); + prepare_decimal_comma(bytes, scratch); as ParsedBuffer>::parse_bytes( buf, scratch, @@ -891,7 +891,7 @@ impl Buffer { } #[inline] -fn prepare_decimal_float(bytes: &[u8], scratch: &mut Vec) { +fn prepare_decimal_comma(bytes: &[u8], scratch: &mut Vec) { scratch.clear(); scratch.reserve(bytes.len()); diff --git a/crates/polars-io/src/csv/parser.rs b/crates/polars-io/src/csv/parser.rs index 4627414f4faf..179fb7b6e3fd 100644 --- a/crates/polars-io/src/csv/parser.rs +++ b/crates/polars-io/src/csv/parser.rs @@ -39,7 +39,7 @@ pub struct CsvParserOptions { pub schema_overwrite: Option, pub schema: Option, pub null_values: Option, - pub decimal_float: bool, + pub decimal_comma: bool, } /// Read the number of rows without parsing columns diff --git a/crates/polars-io/src/csv/read.rs b/crates/polars-io/src/csv/read.rs index 9b170c498643..d1cfda715076 100644 --- a/crates/polars-io/src/csv/read.rs +++ b/crates/polars-io/src/csv/read.rs @@ -162,7 +162,7 @@ where has_header: bool, ignore_errors: bool, eol_char: u8, - decimal_float: bool, + decimal_comma: bool, } impl<'a, R> CsvReader<'a, R> @@ -374,8 +374,8 @@ where } /// Parse floats with decimals. - pub fn with_decimal_float(mut self, toggle: bool) -> Self { - self.decimal_float = toggle; + pub fn with_decimal_comma(mut self, toggle: bool) -> Self { + self.decimal_comma = toggle; self } } @@ -429,7 +429,7 @@ impl<'a, R: MmapBytesReader + 'a> CsvReader<'a, R> { self.try_parse_dates, self.raise_if_empty, self.truncate_ragged_lines, - self.decimal_float, + self.decimal_comma, ) } @@ -537,7 +537,7 @@ impl<'a> CsvReader<'a, Box> { self.try_parse_dates, self.raise_if_empty, &mut self.n_threads, - self.decimal_float, + self.decimal_comma, )?; let schema = Arc::new(inferred_schema); Ok(to_batched_owned_mmap(self, schema)) @@ -568,7 +568,7 @@ impl<'a> CsvReader<'a, Box> { self.try_parse_dates, self.raise_if_empty, &mut self.n_threads, - self.decimal_float, + self.decimal_comma, )?; let schema = Arc::new(inferred_schema); Ok(to_batched_owned_read(self, schema)) @@ -614,7 +614,7 @@ where row_index: None, raise_if_empty: true, truncate_ragged_lines: false, - decimal_float: false, + decimal_comma: false, } } diff --git a/crates/polars-io/src/csv/read_impl/batched_mmap.rs b/crates/polars-io/src/csv/read_impl/batched_mmap.rs index 71d71e9ee987..6986628eef75 100644 --- a/crates/polars-io/src/csv/read_impl/batched_mmap.rs +++ b/crates/polars-io/src/csv/read_impl/batched_mmap.rs @@ -164,7 +164,7 @@ impl<'a> CoreReader<'a> { schema: self.schema, rows_read: 0, _cat_lock, - decimal_float: self.decimal_float, + decimal_comma: self.decimal_comma, }) } } @@ -194,7 +194,7 @@ pub struct BatchedCsvReaderMmap<'a> { _cat_lock: Option, #[cfg(not(feature = "dtype-categorical"))] _cat_lock: Option, - decimal_float: bool, + decimal_comma: bool, } impl<'a> BatchedCsvReaderMmap<'a> { @@ -245,7 +245,7 @@ impl<'a> BatchedCsvReaderMmap<'a> { self.chunk_size, stop_at_nbytes, self.starting_point_offset, - self.decimal_float, + self.decimal_comma, )?; cast_columns(&mut df, &self.to_cast, false, self.ignore_errors)?; diff --git a/crates/polars-io/src/csv/read_impl/batched_read.rs b/crates/polars-io/src/csv/read_impl/batched_read.rs index 5edb9a250194..92e924107ee3 100644 --- a/crates/polars-io/src/csv/read_impl/batched_read.rs +++ b/crates/polars-io/src/csv/read_impl/batched_read.rs @@ -247,7 +247,7 @@ impl<'a> CoreReader<'a> { schema: self.schema, rows_read: 0, _cat_lock, - decimal_float: self.decimal_float, + decimal_comma: self.decimal_comma, }) } } @@ -277,7 +277,7 @@ pub struct BatchedCsvReaderRead<'a> { _cat_lock: Option, #[cfg(not(feature = "dtype-categorical"))] _cat_lock: Option, - decimal_float: bool, + decimal_comma: bool, } // impl<'a> BatchedCsvReaderRead<'a> { @@ -342,7 +342,7 @@ impl<'a> BatchedCsvReaderRead<'a> { self.chunk_size, stop_at_n_bytes, self.starting_point_offset, - self.decimal_float, + self.decimal_comma, )?; cast_columns(&mut df, &self.to_cast, false, self.ignore_errors)?; diff --git a/crates/polars-io/src/csv/read_impl/mod.rs b/crates/polars-io/src/csv/read_impl/mod.rs index 1d863d080324..c5854a43e6e4 100644 --- a/crates/polars-io/src/csv/read_impl/mod.rs +++ b/crates/polars-io/src/csv/read_impl/mod.rs @@ -106,7 +106,7 @@ pub(crate) struct CoreReader<'a> { sample_size: usize, chunk_size: usize, low_memory: bool, - decimal_float: bool, + decimal_comma: bool, comment_prefix: Option, quote_char: Option, eol_char: u8, @@ -160,9 +160,9 @@ impl<'a> CoreReader<'a> { try_parse_dates: bool, raise_if_empty: bool, truncate_ragged_lines: bool, - decimal_float: bool, + decimal_comma: bool, ) -> PolarsResult> { - check_decimal_float(decimal_float, separator.unwrap_or(b','))?; + check_decimal_comma(decimal_comma, separator.unwrap_or(b','))?; #[cfg(any(feature = "decompress", feature = "decompress-fast"))] let mut reader_bytes = reader_bytes; @@ -209,7 +209,7 @@ impl<'a> CoreReader<'a> { try_parse_dates, raise_if_empty, &mut n_threads, - decimal_float, + decimal_comma, )?; Arc::new(inferred_schema) }, @@ -264,7 +264,7 @@ impl<'a> CoreReader<'a> { to_cast, row_index, truncate_ragged_lines, - decimal_float, + decimal_comma, }) } @@ -510,7 +510,7 @@ impl<'a> CoreReader<'a> { schema, self.quote_char, self.encoding, - self.decimal_float, + self.decimal_comma, )?; let local_bytes = &bytes[read..stop_at_nbytes]; @@ -595,7 +595,7 @@ impl<'a> CoreReader<'a> { usize::MAX, stop_at_nbytes, starting_point_offset, - self.decimal_float, + self.decimal_comma, )?; cast_columns(&mut df, &self.to_cast, false, self.ignore_errors)?; @@ -619,7 +619,7 @@ impl<'a> CoreReader<'a> { self.schema.as_ref(), self.quote_char, self.encoding, - self.decimal_float, + self.decimal_comma, )?; parse_lines( @@ -702,7 +702,7 @@ fn read_chunk( chunk_size: usize, stop_at_nbytes: usize, starting_point_offset: Option, - decimal_float: bool, + decimal_comma: bool, ) -> PolarsResult { let mut read = bytes_offset_thread; // There's an off-by-one error somewhere in the reading code, where it reads @@ -716,7 +716,7 @@ fn read_chunk( schema, quote_char, encoding, - decimal_float, + decimal_comma, )?; let mut last_read = usize::MAX; diff --git a/crates/polars-io/src/csv/utils.rs b/crates/polars-io/src/csv/utils.rs index b29e251ebaad..db02550c1cbb 100644 --- a/crates/polars-io/src/csv/utils.rs +++ b/crates/polars-io/src/csv/utils.rs @@ -60,7 +60,7 @@ pub(crate) fn get_file_chunks( } /// Infer the data type of a record -fn infer_field_schema(string: &str, try_parse_dates: bool, decimal_float: bool) -> DataType { +fn infer_field_schema(string: &str, try_parse_dates: bool, decimal_comma: bool) -> DataType { // when quoting is enabled in the reader, these quotes aren't escaped, we default to // String for them if string.starts_with('"') { @@ -91,8 +91,8 @@ fn infer_field_schema(string: &str, try_parse_dates: bool, decimal_float: bool) // match regex in a particular order else if BOOLEAN_RE.is_match(string) { DataType::Boolean - } else if !decimal_float && FLOAT_RE.is_match(string) - || decimal_float && FLOAT_RE_DECIMAL.is_match(string) + } else if !decimal_comma && FLOAT_RE.is_match(string) + || decimal_comma && FLOAT_RE_DECIMAL.is_match(string) { DataType::Float64 } else if INTEGER_RE.is_match(string) { @@ -154,7 +154,7 @@ pub fn infer_file_schema_inner( recursion_count: u8, raise_if_empty: bool, n_threads: &mut Option, - decimal_float: bool, + decimal_comma: bool, ) -> PolarsResult<(Schema, usize, usize)> { // keep track so that we can determine the amount of bytes read let start_ptr = reader_bytes.as_ptr() as usize; @@ -255,7 +255,7 @@ pub fn infer_file_schema_inner( recursion_count + 1, raise_if_empty, n_threads, - decimal_float, + decimal_comma, ); } else if !raise_if_empty { return Ok((Schema::new(), 0, 0)); @@ -333,17 +333,17 @@ pub fn infer_file_schema_inner( }; let s = parse_bytes_with_encoding(slice_escaped, encoding)?; let dtype = match &null_values { - None => Some(infer_field_schema(&s, try_parse_dates, decimal_float)), + None => Some(infer_field_schema(&s, try_parse_dates, decimal_comma)), Some(NullValues::AllColumns(names)) => { if !names.iter().any(|nv| nv == s.as_ref()) { - Some(infer_field_schema(&s, try_parse_dates, decimal_float)) + Some(infer_field_schema(&s, try_parse_dates, decimal_comma)) } else { None } }, Some(NullValues::AllColumnsSingle(name)) => { if s.as_ref() != name { - Some(infer_field_schema(&s, try_parse_dates, decimal_float)) + Some(infer_field_schema(&s, try_parse_dates, decimal_comma)) } else { None } @@ -356,12 +356,12 @@ pub fn infer_file_schema_inner( if let Some(null_name) = null_name { if null_name.1 != s.as_ref() { - Some(infer_field_schema(&s, try_parse_dates, decimal_float)) + Some(infer_field_schema(&s, try_parse_dates, decimal_comma)) } else { None } } else { - Some(infer_field_schema(&s, try_parse_dates, decimal_float)) + Some(infer_field_schema(&s, try_parse_dates, decimal_comma)) } }, }; @@ -459,16 +459,16 @@ pub fn infer_file_schema_inner( recursion_count + 1, raise_if_empty, n_threads, - decimal_float, + decimal_comma, ); } Ok((Schema::from_iter(fields), rows_count, end_ptr - start_ptr)) } -pub(super) fn check_decimal_float(decimal_float: bool, separator: u8) -> PolarsResult<()> { - if decimal_float { - polars_ensure!(b',' != separator, InvalidOperation: "'decimal_float' argument cannot be combined with ',' quote char") +pub(super) fn check_decimal_comma(decimal_comma: bool, separator: u8) -> PolarsResult<()> { + if decimal_comma { + polars_ensure!(b',' != separator, InvalidOperation: "'decimal_comma' argument cannot be combined with ',' quote char") } Ok(()) } @@ -500,9 +500,9 @@ pub fn infer_file_schema( try_parse_dates: bool, raise_if_empty: bool, n_threads: &mut Option, - decimal_float: bool, + decimal_comma: bool, ) -> PolarsResult<(Schema, usize, usize)> { - check_decimal_float(decimal_float, separator)?; + check_decimal_comma(decimal_comma, separator)?; infer_file_schema_inner( reader_bytes, separator, @@ -519,7 +519,7 @@ pub fn infer_file_schema( 0, raise_if_empty, n_threads, - decimal_float, + decimal_comma, ) } diff --git a/crates/polars-lazy/src/physical_plan/executors/scan/csv.rs b/crates/polars-lazy/src/physical_plan/executors/scan/csv.rs index 125c2f2cbd76..63ad38bcfa12 100644 --- a/crates/polars-lazy/src/physical_plan/executors/scan/csv.rs +++ b/crates/polars-lazy/src/physical_plan/executors/scan/csv.rs @@ -45,7 +45,7 @@ impl CsvExec { .with_try_parse_dates(self.options.try_parse_dates) .with_n_threads(self.options.n_threads) .truncate_ragged_lines(self.options.truncate_ragged_lines) - .with_decimal_float(self.options.decimal_float) + .with_decimal_comma(self.options.decimal_comma) .raise_if_empty(self.options.raise_if_empty) .finish() } diff --git a/crates/polars-lazy/src/scan/csv.rs b/crates/polars-lazy/src/scan/csv.rs index 96f7ce083f4f..9728792ff6fd 100644 --- a/crates/polars-lazy/src/scan/csv.rs +++ b/crates/polars-lazy/src/scan/csv.rs @@ -36,7 +36,7 @@ pub struct LazyCsvReader { try_parse_dates: bool, raise_if_empty: bool, n_threads: Option, - decimal_float: bool, + decimal_comma: bool, } #[cfg(feature = "csv")] @@ -72,7 +72,7 @@ impl LazyCsvReader { raise_if_empty: true, truncate_ragged_lines: false, n_threads: None, - decimal_float: false, + decimal_comma: false, } } @@ -234,8 +234,8 @@ impl LazyCsvReader { } #[must_use] - pub fn with_decimal_float(mut self, toggle: bool) -> Self { - self.decimal_float = toggle; + pub fn with_decimal_comma(mut self, toggle: bool) -> Self { + self.decimal_comma = toggle; self } @@ -274,7 +274,7 @@ impl LazyCsvReader { self.try_parse_dates, self.raise_if_empty, &mut self.n_threads, - self.decimal_float, + self.decimal_comma, )?; let mut schema = f(schema)?; @@ -315,7 +315,7 @@ impl LazyFileListReader for LazyCsvReader { self.raise_if_empty, self.truncate_ragged_lines, self.n_threads, - self.decimal_float, + self.decimal_comma, )? .build() .into(); diff --git a/crates/polars-pipe/src/executors/sources/csv.rs b/crates/polars-pipe/src/executors/sources/csv.rs index 286690c61e84..e2191b4fc6b2 100644 --- a/crates/polars-pipe/src/executors/sources/csv.rs +++ b/crates/polars-pipe/src/executors/sources/csv.rs @@ -82,7 +82,7 @@ impl CsvSource { .with_n_threads(options.n_threads) .with_try_parse_dates(options.try_parse_dates) .truncate_ragged_lines(options.truncate_ragged_lines) - .with_decimal_float(options.decimal_float) + .with_decimal_comma(options.decimal_comma) .raise_if_empty(options.raise_if_empty); let reader = Box::new(reader); diff --git a/crates/polars-plan/src/logical_plan/builder_dsl.rs b/crates/polars-plan/src/logical_plan/builder_dsl.rs index 5c7f032fbe80..9b899ec997ba 100644 --- a/crates/polars-plan/src/logical_plan/builder_dsl.rs +++ b/crates/polars-plan/src/logical_plan/builder_dsl.rs @@ -191,7 +191,7 @@ impl DslBuilder { raise_if_empty: bool, truncate_ragged_lines: bool, n_threads: Option, - decimal_float: bool, + decimal_comma: bool, ) -> PolarsResult { let path = path.into(); @@ -235,7 +235,7 @@ impl DslBuilder { schema_overwrite, skip_rows_after_header, infer_schema_length, - decimal_float, + decimal_comma, }, }, } diff --git a/crates/polars-plan/src/logical_plan/conversion/scans.rs b/crates/polars-plan/src/logical_plan/conversion/scans.rs index 341617604985..10f3f4bb3979 100644 --- a/crates/polars-plan/src/logical_plan/conversion/scans.rs +++ b/crates/polars-plan/src/logical_plan/conversion/scans.rs @@ -162,7 +162,7 @@ pub(super) fn csv_file_info( csv_options.try_parse_dates, csv_options.raise_if_empty, &mut csv_options.n_threads, - csv_options.decimal_float, + csv_options.decimal_comma, )?; let mut schema = csv_options diff --git a/py-polars/polars/io/csv/batched_reader.py b/py-polars/polars/io/csv/batched_reader.py index beeebf523788..5a007239cb86 100644 --- a/py-polars/polars/io/csv/batched_reader.py +++ b/py-polars/polars/io/csv/batched_reader.py @@ -55,7 +55,7 @@ def __init__( new_columns: Sequence[str] | None = None, raise_if_empty: bool = True, truncate_ragged_lines: bool = False, - decimal_float: bool = False, + decimal_comma: bool = False, ): path = normalize_filepath(source) @@ -103,7 +103,7 @@ def __init__( eol_char=eol_char, raise_if_empty=raise_if_empty, truncate_ragged_lines=truncate_ragged_lines, - decimal_float=decimal_float, + decimal_comma=decimal_comma, ) self.new_columns = new_columns diff --git a/py-polars/polars/io/csv/functions.py b/py-polars/polars/io/csv/functions.py index 8c3c77835bd5..10c558123a11 100644 --- a/py-polars/polars/io/csv/functions.py +++ b/py-polars/polars/io/csv/functions.py @@ -69,7 +69,7 @@ def read_csv( eol_char: str = "\n", raise_if_empty: bool = True, truncate_ragged_lines: bool = False, - decimal_float: bool = False, + decimal_comma: bool = False, ) -> DataFrame: r""" Read a CSV file into a DataFrame. @@ -186,7 +186,7 @@ def read_csv( is set to False, an empty DataFrame (with no columns) is returned instead. truncate_ragged_lines Truncate lines that are longer than the schema. - decimal_float + decimal_comma Parse floats with decimal signs Returns @@ -441,7 +441,7 @@ def read_csv( eol_char=eol_char, raise_if_empty=raise_if_empty, truncate_ragged_lines=truncate_ragged_lines, - decimal_float=decimal_float, + decimal_comma=decimal_comma, ) if new_columns: @@ -478,7 +478,7 @@ def _read_csv_impl( eol_char: str = "\n", raise_if_empty: bool = True, truncate_ragged_lines: bool = False, - decimal_float: bool = False, + decimal_comma: bool = False, ) -> DataFrame: path: str | None if isinstance(source, (str, Path)): @@ -541,7 +541,7 @@ def _read_csv_impl( eol_char=eol_char, raise_if_empty=raise_if_empty, truncate_ragged_lines=truncate_ragged_lines, - decimal_float=decimal_float, + decimal_comma=decimal_comma, ) if columns is None: return scan.collect() @@ -585,7 +585,7 @@ def _read_csv_impl( eol_char=eol_char, raise_if_empty=raise_if_empty, truncate_ragged_lines=truncate_ragged_lines, - decimal_float=decimal_float, + decimal_comma=decimal_comma, schema=schema, ) return wrap_df(pydf) @@ -624,7 +624,7 @@ def read_csv_batched( sample_size: int = 1024, eol_char: str = "\n", raise_if_empty: bool = True, - decimal_float: bool = False, + decimal_comma: bool = False, ) -> BatchedCsvReader: r""" Read a CSV file in batches. @@ -725,7 +725,7 @@ def read_csv_batched( raise_if_empty When there is no data in the source,`NoDataError` is raised. If this parameter is set to False, `None` will be returned from `next_batches(n)` instead. - decimal_float + decimal_comma Parse floats with decimal signs Returns @@ -887,7 +887,7 @@ def read_csv_batched( eol_char=eol_char, new_columns=new_columns, raise_if_empty=raise_if_empty, - decimal_float=decimal_float, + decimal_comma=decimal_comma, ) @@ -924,7 +924,7 @@ def scan_csv( new_columns: Sequence[str] | None = None, raise_if_empty: bool = True, truncate_ragged_lines: bool = False, - decimal_float: bool = False, + decimal_comma: bool = False, ) -> LazyFrame: r""" Lazily read from a CSV file or multiple files via glob patterns. @@ -1017,7 +1017,7 @@ def scan_csv( is set to False, an empty LazyFrame (with no columns) is returned instead. truncate_ragged_lines Truncate lines that are longer than the schema. - decimal_float + decimal_comma Parse floats with decimal signs Returns @@ -1137,7 +1137,7 @@ def with_column_names(cols: list[str]) -> list[str]: eol_char=eol_char, raise_if_empty=raise_if_empty, truncate_ragged_lines=truncate_ragged_lines, - decimal_float=decimal_float, + decimal_comma=decimal_comma, ) @@ -1168,7 +1168,7 @@ def _scan_csv_impl( eol_char: str = "\n", raise_if_empty: bool = True, truncate_ragged_lines: bool = True, - decimal_float: bool = False, + decimal_comma: bool = False, ) -> LazyFrame: dtype_list: list[tuple[str, PolarsDataType]] | None = None if dtypes is not None: @@ -1208,7 +1208,7 @@ def _scan_csv_impl( eol_char=eol_char, raise_if_empty=raise_if_empty, truncate_ragged_lines=truncate_ragged_lines, - decimal_float=decimal_float, + decimal_comma=decimal_comma, schema=schema, ) return wrap_ldf(pylf) diff --git a/py-polars/src/batched_csv.rs b/py-polars/src/batched_csv.rs index ba862cd60c0b..b0f468d9069d 100644 --- a/py-polars/src/batched_csv.rs +++ b/py-polars/src/batched_csv.rs @@ -30,7 +30,7 @@ impl PyBatchedCsv { projection, separator, rechunk, columns, encoding, n_threads, path, overwrite_dtype, overwrite_dtype_slice, low_memory, comment_prefix, quote_char, null_values, missing_utf8_is_empty_string, try_parse_dates, skip_rows_after_header, row_index, - sample_size, eol_char, raise_if_empty, truncate_ragged_lines, decimal_float) + sample_size, eol_char, raise_if_empty, truncate_ragged_lines, decimal_comma) )] fn new( infer_schema_length: Option, @@ -60,7 +60,7 @@ impl PyBatchedCsv { eol_char: &str, raise_if_empty: bool, truncate_ragged_lines: bool, - decimal_float: bool, + decimal_comma: bool, ) -> PyResult { let null_values = null_values.map(|w| w.0); let eol_char = eol_char.as_bytes()[0]; @@ -119,7 +119,7 @@ impl PyBatchedCsv { .with_row_index(row_index) .sample_size(sample_size) .truncate_ragged_lines(truncate_ragged_lines) - .with_decimal_float(decimal_float) + .with_decimal_comma(decimal_comma) .raise_if_empty(raise_if_empty); let reader = if low_memory { diff --git a/py-polars/src/dataframe/io.rs b/py-polars/src/dataframe/io.rs index 23e3f1bae3d4..7691f6bb16f9 100644 --- a/py-polars/src/dataframe/io.rs +++ b/py-polars/src/dataframe/io.rs @@ -23,7 +23,7 @@ impl PyDataFrame { skip_rows, projection, separator, rechunk, columns, encoding, n_threads, path, overwrite_dtype, overwrite_dtype_slice, low_memory, comment_prefix, quote_char, null_values, missing_utf8_is_empty_string, try_parse_dates, skip_rows_after_header, - row_index, sample_size, eol_char, raise_if_empty, truncate_ragged_lines, decimal_float, schema) + row_index, sample_size, eol_char, raise_if_empty, truncate_ragged_lines, decimal_comma, schema) )] pub fn read_csv( py: Python, @@ -55,7 +55,7 @@ impl PyDataFrame { eol_char: &str, raise_if_empty: bool, truncate_ragged_lines: bool, - decimal_float: bool, + decimal_comma: bool, schema: Option>, ) -> PyResult { let null_values = null_values.map(|w| w.0); @@ -111,7 +111,7 @@ impl PyDataFrame { .sample_size(sample_size) .raise_if_empty(raise_if_empty) .truncate_ragged_lines(truncate_ragged_lines) - .with_decimal_float(decimal_float) + .with_decimal_comma(decimal_comma) .finish() .map_err(PyPolarsErr::from) })?; diff --git a/py-polars/src/lazyframe/mod.rs b/py-polars/src/lazyframe/mod.rs index f231044ba242..3f0cca0d1215 100644 --- a/py-polars/src/lazyframe/mod.rs +++ b/py-polars/src/lazyframe/mod.rs @@ -141,7 +141,7 @@ impl PyLazyFrame { #[pyo3(signature = (path, paths, separator, has_header, ignore_errors, skip_rows, n_rows, cache, overwrite_dtype, low_memory, comment_prefix, quote_char, null_values, missing_utf8_is_empty_string, infer_schema_length, with_schema_modify, rechunk, skip_rows_after_header, - encoding, row_index, try_parse_dates, eol_char, raise_if_empty, truncate_ragged_lines, decimal_float, schema + encoding, row_index, try_parse_dates, eol_char, raise_if_empty, truncate_ragged_lines, decimal_comma, schema ) )] fn new_from_csv( @@ -169,7 +169,7 @@ impl PyLazyFrame { eol_char: &str, raise_if_empty: bool, truncate_ragged_lines: bool, - decimal_float: bool, + decimal_comma: bool, schema: Option>, ) -> PyResult { let null_values = null_values.map(|w| w.0); @@ -213,7 +213,7 @@ impl PyLazyFrame { .with_null_values(null_values) .with_missing_is_null(!missing_utf8_is_empty_string) .truncate_ragged_lines(truncate_ragged_lines) - .with_decimal_float(decimal_float) + .with_decimal_comma(decimal_comma) .raise_if_empty(raise_if_empty); if let Some(lambda) = with_schema_modify { diff --git a/py-polars/tests/unit/io/test_csv.py b/py-polars/tests/unit/io/test_csv.py index 51288922f7f9..80d2058e61fe 100644 --- a/py-polars/tests/unit/io/test_csv.py +++ b/py-polars/tests/unit/io/test_csv.py @@ -2062,15 +2062,15 @@ def test_skip_rows_after_header_pyarrow(use_pyarrow: bool) -> None: def test_csv_float_decimal() -> None: floats = b"a;b\n12,239;1,233\n13,908;87,32" - read = pl.read_csv(floats, decimal_float=True, separator=";") + read = pl.read_csv(floats, decimal_comma=True, separator=";") assert read.dtypes == [pl.Float64] * 2 assert read.to_dict(as_series=False) == {"a": [12.239, 13.908], "b": [1.233, 87.32]} floats = b"a;b\n12,239;1,233\n13,908;87,32" with pytest.raises( - pl.InvalidOperationError, match=r"'decimal_float' argument cannot be combined" + pl.InvalidOperationError, match=r"'decimal_comma' argument cannot be combined" ): - pl.read_csv(floats, decimal_float=True) + pl.read_csv(floats, decimal_comma=True) def test_fsspec_not_available(monkeypatch: pytest.MonkeyPatch) -> None: