From abdc7107e72afe003c4e42548fc6e48c2226c141 Mon Sep 17 00:00:00 2001 From: joaoavf Date: Fri, 9 Mar 2018 14:04:34 +0000 Subject: [PATCH 1/8] DOC: Improved the docstring of errors.ParserWarning --- pandas/errors/__init__.py | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/pandas/errors/__init__.py b/pandas/errors/__init__.py index af4e83f506257..4210857556acc 100644 --- a/pandas/errors/__init__.py +++ b/pandas/errors/__init__.py @@ -53,10 +53,37 @@ class EmptyDataError(ValueError): class ParserWarning(Warning): """ - Warning that is raised in `pd.read_csv` whenever it is necessary - to change parsers (generally from 'c' to 'python') contrary to the - one specified by the user due to lack of support or functionality for - parsing particular attributes of a CSV file with the requested engine. + Warning raised in `pd.read_csv` and `pd.read_table` when it is + necessary to change parsers, generally from 'c' to 'python'. + + It happens due to lack of support or functionality for parsing + particular attributes of a CSV file with the requested engine. + + Currently, C-unsupported options include the following parameters: + + 1. `sep` other than a single character (e.g. regex separators) + 2. `skipfooter` higher than 0 + 3. `sep=None` with `delim_whitespace=False` + + The warning can be avoided by adding `engine='python'` as a parameter + in `pd.read_csv` and `pd.read_table` methods. + + Examples + -------- + Using a `sep` in `pd.read_csv` other than a single character: + + >>> import io + >>> csv = u'''a;b;c + ... 1;1,8 + ... 1;2,1''' + >>> df = pd.read_csv(io.StringIO(csv), sep='[;,]') + Traceback (most recent call last): + ... + ParserWarning: Falling back to the 'python' engine... + + Adding `engine='python'` to `pd.read_csv` removes the Warning: + + >>> df = pd.read_csv(io.StringIO(csv), sep='[;,]', engine='python') """ From 0607602f49c0a985546ab0c2d22cd288c9fc2093 Mon Sep 17 00:00:00 2001 From: joaoavf Date: Fri, 9 Mar 2018 14:29:33 +0000 Subject: [PATCH 2/8] Correcting whitespace issue on line 58 --- pandas/errors/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/errors/__init__.py b/pandas/errors/__init__.py index 4210857556acc..0187debd62612 100644 --- a/pandas/errors/__init__.py +++ b/pandas/errors/__init__.py @@ -55,7 +55,7 @@ class ParserWarning(Warning): """ Warning raised in `pd.read_csv` and `pd.read_table` when it is necessary to change parsers, generally from 'c' to 'python'. - + It happens due to lack of support or functionality for parsing particular attributes of a CSV file with the requested engine. From 850a3fe15c1838813fc9cc0a3889718e7af0f941 Mon Sep 17 00:00:00 2001 From: joaoavf Date: Fri, 9 Mar 2018 16:33:54 +0000 Subject: [PATCH 3/8] Converting the short summary to one line. --- pandas/errors/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/errors/__init__.py b/pandas/errors/__init__.py index 0187debd62612..5dd05d43ea0cf 100644 --- a/pandas/errors/__init__.py +++ b/pandas/errors/__init__.py @@ -53,7 +53,9 @@ class EmptyDataError(ValueError): class ParserWarning(Warning): """ - Warning raised in `pd.read_csv` and `pd.read_table` when it is + Warning raised when reading a file that doesn't use the default parser. + + Thrown by `pd.read_csv` and `pd.read_table` when it is necessary to change parsers, generally from 'c' to 'python'. It happens due to lack of support or functionality for parsing From 815bf0ee27cece0a380eb776e76828b983fc2dee Mon Sep 17 00:00:00 2001 From: joaoavf Date: Fri, 9 Mar 2018 16:41:28 +0000 Subject: [PATCH 4/8] minor formatting changes --- pandas/errors/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/errors/__init__.py b/pandas/errors/__init__.py index 5dd05d43ea0cf..b0e281097ee2b 100644 --- a/pandas/errors/__init__.py +++ b/pandas/errors/__init__.py @@ -55,8 +55,8 @@ class ParserWarning(Warning): """ Warning raised when reading a file that doesn't use the default parser. - Thrown by `pd.read_csv` and `pd.read_table` when it is - necessary to change parsers, generally from 'c' to 'python'. + Thrown by `pd.read_csv` and `pd.read_table` when it is necessary to + change parsers, generally from 'c' to 'python'. It happens due to lack of support or functionality for parsing particular attributes of a CSV file with the requested engine. From b12907e45b88b9f1ec49fb48044ab418ada293bf Mon Sep 17 00:00:00 2001 From: joaoavf Date: Fri, 9 Mar 2018 16:46:06 +0000 Subject: [PATCH 5/8] Added a 'See Also' section --- pandas/errors/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pandas/errors/__init__.py b/pandas/errors/__init__.py index b0e281097ee2b..38f3a1c91e631 100644 --- a/pandas/errors/__init__.py +++ b/pandas/errors/__init__.py @@ -70,6 +70,11 @@ class ParserWarning(Warning): The warning can be avoided by adding `engine='python'` as a parameter in `pd.read_csv` and `pd.read_table` methods. + See Also + -------- + pd.read_csv : Read CSV (comma-separated) file into DataFrame. + pd.read_table : Read general delimited file into DataFrame. + Examples -------- Using a `sep` in `pd.read_csv` other than a single character: From 8fe1c0409bfa04a18c5f091d07a5e77dd29bfe15 Mon Sep 17 00:00:00 2001 From: joaoavf <30525975+joaoavf@users.noreply.github.com> Date: Sat, 10 Mar 2018 13:36:03 +0000 Subject: [PATCH 6/8] Making changes request by jreback and minor formatting changes --- pandas/errors/__init__.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pandas/errors/__init__.py b/pandas/errors/__init__.py index 38f3a1c91e631..b33c936208349 100644 --- a/pandas/errors/__init__.py +++ b/pandas/errors/__init__.py @@ -55,20 +55,20 @@ class ParserWarning(Warning): """ Warning raised when reading a file that doesn't use the default parser. - Thrown by `pd.read_csv` and `pd.read_table` when it is necessary to - change parsers, generally from 'c' to 'python'. + Raised by `pd.read_csv` and `pd.read_table` when it is necessary to change + parsers, generally from the default 'c' parser to 'python'. - It happens due to lack of support or functionality for parsing - particular attributes of a CSV file with the requested engine. + It happens due to a lack of support or functionality for parsing a + particular attribute of a CSV file with the requested engine. - Currently, C-unsupported options include the following parameters: + Currently, 'c' unsupported options include the following parameters: 1. `sep` other than a single character (e.g. regex separators) 2. `skipfooter` higher than 0 3. `sep=None` with `delim_whitespace=False` - The warning can be avoided by adding `engine='python'` as a parameter - in `pd.read_csv` and `pd.read_table` methods. + The warning can be avoided by adding `engine='python'` as a parameter in + `pd.read_csv` and `pd.read_table` methods. See Also -------- From 37c9f96fc1e3ba65fc331c037f0009c21ee65943 Mon Sep 17 00:00:00 2001 From: joaoavf <30525975+joaoavf@users.noreply.github.com> Date: Sat, 10 Mar 2018 13:38:39 +0000 Subject: [PATCH 7/8] Adding the default 'c' parser to the short summary --- pandas/errors/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/errors/__init__.py b/pandas/errors/__init__.py index b33c936208349..d3fddaf768e26 100644 --- a/pandas/errors/__init__.py +++ b/pandas/errors/__init__.py @@ -53,7 +53,7 @@ class EmptyDataError(ValueError): class ParserWarning(Warning): """ - Warning raised when reading a file that doesn't use the default parser. + Warning raised when reading a file that doesn't use the default 'c' parser. Raised by `pd.read_csv` and `pd.read_table` when it is necessary to change parsers, generally from the default 'c' parser to 'python'. From 17687b59e5b288962fb4f51a2d0a1457a2b9fcae Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Thu, 15 Mar 2018 14:28:17 -0500 Subject: [PATCH 8/8] Pass doctests [ci skip] [ci skip] --- pandas/errors/__init__.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pandas/errors/__init__.py b/pandas/errors/__init__.py index d3fddaf768e26..ee1a2ba777559 100644 --- a/pandas/errors/__init__.py +++ b/pandas/errors/__init__.py @@ -84,9 +84,7 @@ class ParserWarning(Warning): ... 1;1,8 ... 1;2,1''' >>> df = pd.read_csv(io.StringIO(csv), sep='[;,]') - Traceback (most recent call last): - ... - ParserWarning: Falling back to the 'python' engine... + ... # ParserWarning: Falling back to the 'python' engine... Adding `engine='python'` to `pd.read_csv` removes the Warning: