Skip to content

Commit

Permalink
Revert changes to type changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
svaningelgem committed Oct 8, 2023
1 parent 203bcdf commit c630dff
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
8 changes: 4 additions & 4 deletions py-polars/polars/dataframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ def _read_csv(
n_rows,
skip_rows,
projection,
ord(separator),
separator,
rechunk,
columns,
encoding,
Expand All @@ -785,15 +785,15 @@ def _read_csv(
dtype_list,
dtype_slice,
low_memory,
ord(comment_char) if comment_char else None,
ord(quote_char) if quote_char else None,
comment_char,
quote_char,
processed_null_values,
missing_utf8_is_empty_string,
try_parse_dates,
skip_rows_after_header,
_prepare_row_count_args(row_count_name, row_count_offset),
sample_size=sample_size,
eol_char=ord(eol_char),
eol_char=eol_char,
raise_if_empty=raise_if_empty,
truncate_ragged_lines=truncate_ragged_lines,
schema=schema,
Expand Down
8 changes: 4 additions & 4 deletions py-polars/polars/lazyframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,16 +359,16 @@ def _scan_csv(
self = cls.__new__(cls)
self._ldf = PyLazyFrame.new_from_csv(
source,
ord(separator),
separator,
has_header,
ignore_errors,
skip_rows,
n_rows,
cache,
dtype_list,
low_memory,
ord(comment_char) if comment_char else None,
ord(quote_char) if quote_char else None,
comment_char,
quote_char,
processed_null_values,
missing_utf8_is_empty_string,
infer_schema_length,
Expand All @@ -378,7 +378,7 @@ def _scan_csv(
encoding,
_prepare_row_count_args(row_count_name, row_count_offset),
try_parse_dates,
eol_char=ord(eol_char),
eol_char=eol_char,
raise_if_empty=raise_if_empty,
truncate_ragged_lines=truncate_ragged_lines,
schema=schema,
Expand Down
13 changes: 8 additions & 5 deletions py-polars/src/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl PyDataFrame {
n_rows: Option<usize>,
skip_rows: usize,
projection: Option<Vec<usize>>,
separator: u8,
separator: &str,
rechunk: bool,
columns: Option<Vec<String>>,
encoding: Wrap<CsvEncoding>,
Expand All @@ -188,21 +188,24 @@ impl PyDataFrame {
overwrite_dtype: Option<Vec<(&str, Wrap<DataType>)>>,
overwrite_dtype_slice: Option<Vec<Wrap<DataType>>>,
low_memory: bool,
comment_char: Option<u8>,
quote_char: Option<u8>,
comment_char: Option<&str>,
quote_char: Option<&str>,
null_values: Option<Wrap<NullValues>>,
missing_utf8_is_empty_string: bool,
try_parse_dates: bool,
skip_rows_after_header: usize,
row_count: Option<(String, IdxSize)>,
sample_size: usize,
eol_char: u8,
eol_char: &str,
raise_if_empty: bool,
truncate_ragged_lines: bool,
schema: Option<Wrap<Schema>>,
) -> PyResult<Self> {
let null_values = null_values.map(|w| w.0);
let comment_char = comment_char.map(|s| s.as_bytes()[0]);
let eol_char = eol_char.as_bytes()[0];
let row_count = row_count.map(|(name, offset)| RowCount { name, offset });
let quote_char = quote_char.and_then(|s| s.as_bytes().first().copied());

let overwrite_dtype = overwrite_dtype.map(|overwrite_dtype| {
overwrite_dtype
Expand All @@ -226,7 +229,7 @@ impl PyDataFrame {
.infer_schema(infer_schema_length)
.has_header(has_header)
.with_n_rows(n_rows)
.with_separator(separator)
.with_separator(separator.as_bytes()[0])
.with_skip_rows(skip_rows)
.with_ignore_errors(ignore_errors)
.with_projection(projection)
Expand Down
12 changes: 8 additions & 4 deletions py-polars/src/lazyframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,16 @@ impl PyLazyFrame {
)]
fn new_from_csv(
path: String,
separator: u8,
separator: &str,
has_header: bool,
ignore_errors: bool,
skip_rows: usize,
n_rows: Option<usize>,
cache: bool,
overwrite_dtype: Option<Vec<(&str, Wrap<DataType>)>>,
low_memory: bool,
comment_char: Option<u8>,
quote_char: Option<u8>,
comment_char: Option<&str>,
quote_char: Option<&str>,
null_values: Option<Wrap<NullValues>>,
missing_utf8_is_empty_string: bool,
infer_schema_length: Option<usize>,
Expand All @@ -165,12 +165,16 @@ impl PyLazyFrame {
encoding: Wrap<CsvEncoding>,
row_count: Option<(String, IdxSize)>,
try_parse_dates: bool,
eol_char: u8,
eol_char: &str,
raise_if_empty: bool,
truncate_ragged_lines: bool,
schema: Option<Wrap<Schema>>,
) -> PyResult<Self> {
let null_values = null_values.map(|w| w.0);
let comment_char = comment_char.map(|s| s.as_bytes()[0]);
let quote_char = quote_char.map(|s| s.as_bytes()[0]);
let separator = separator.as_bytes()[0];
let eol_char = eol_char.as_bytes()[0];
let row_count = row_count.map(|(name, offset)| RowCount { name, offset });

let overwrite_dtype = overwrite_dtype.map(|overwrite_dtype| {
Expand Down

0 comments on commit c630dff

Please sign in to comment.