Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
58519d0
TST: Fix doctests for pandas.io.formats.style
Leonardofreua Jul 28, 2021
bb7c3b2
TST: Add link to redirect to Table Visualization user guide
Leonardofreua Jul 28, 2021
fa5a615
TST: Add image to pipe function result
Leonardofreua Jul 28, 2021
378c1f7
TST: Remove unnecessary outputs
Leonardofreua Jul 30, 2021
9dc52e4
TST: Add the output to the Styler.format doctest in to_latex()
Leonardofreua Jul 30, 2021
63535ce
REG: DataFrame.agg where func returns lists and axis=1 (#42762)
rhshadrach Jul 28, 2021
9d72fe0
Fix typing issues for CI (#42770)
Dr-Irv Jul 28, 2021
5ba05f5
BUG: groupby.shift returns different columns when fill_value is speci…
smithto1 Jul 28, 2021
994ff25
PERF: extract_array earlier in DataFrame construction (#42774)
jbrockmendel Jul 28, 2021
6a70067
ENH: `sparse_columns` and `sparse_index` added to `Styler.to_html` (…
attack68 Jul 28, 2021
26e2cd9
TYP: Fix typing for searchsorted (#42788)
rhshadrach Jul 29, 2021
05e0c24
DOC GH42756 Update documentation for pandas.DataFrame.drop to clarify…
Jul 29, 2021
a5d951e
CI: Fix doctests (#42790)
rhshadrach Jul 29, 2021
ebaa9c1
REGR: nanosecond timestamp comparisons to OOB datetimes (#42796)
mzeitlin11 Jul 29, 2021
84f3302
COMPAT: MPL 3.4.0 (#42803)
lithomas1 Jul 29, 2021
76162a4
Delete duplicates and unused code from reshape tests (#42802)
phofl Jul 30, 2021
2c21525
REGR: ValueError raised when both prefix and names are set to None (#…
lithomas1 Jul 30, 2021
13100d8
TST: Add style.py to the doctest check
Leonardofreua Jul 30, 2021
adc540f
TST: fixed eng_formatter doctest for #42671 (#42705)
KrishnaSai2020 Jul 30, 2021
9a35c94
Merge branch 'master' into fix-style-doctests
Leonardofreua Jul 30, 2021
4654dfc
TST: Revert x and y position in some doctests
Leonardofreua Jul 30, 2021
4fe1bea
Merge branch 'fix-style-doctests' of https://github.com/Leonardofreua…
Leonardofreua Jul 30, 2021
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
Prev Previous commit
Next Next commit
REGR: ValueError raised when both prefix and names are set to None (#…
…42690)

* REGR: ValueError raised when both prefix and names are set to None

* Update readers.py

* whitespace

* Update v1.3.1.rst

* Update v1.3.2.rst

* Update readers.py

* Update readers.py

Co-authored-by: Jeff Reback <[email protected]>
  • Loading branch information
2 people authored and Leonardofreua committed Jul 30, 2021
commit 2c21525318ba24dc7c77e51ae490c5e76af3bea1
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.3.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Fixed regressions
- Regression in :meth:`DataFrame.from_records` with empty records (:issue:`42456`)
- Fixed regression in :meth:`DataFrame.shift` where TypeError occurred when shifting DataFrame created by concatenation of slices and fills with values (:issue:`42719`)
- Regression in :meth:`DataFrame.agg` when the ``func`` argument returned lists and ``axis=1`` (:issue:`42727`)
- Fixed regression where :meth:`pandas.read_csv` raised a ``ValueError`` when parameters ``names`` and ``prefix`` were both set to None (:issue:`42387`)
- Fixed regression in comparisons between :class:`Timestamp` object and ``datetime64`` objects outside the implementation bounds for nanosecond ``datetime64`` (:issue:`42794`)
-

Expand Down
7 changes: 6 additions & 1 deletion pandas/io/parsers/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,12 @@ def _refine_defaults_read(
if delimiter and (sep is not lib.no_default):
raise ValueError("Specified a sep and a delimiter; you can only specify one.")

if names is not lib.no_default and prefix is not lib.no_default:
if (
names is not None
and names is not lib.no_default
and prefix is not None
and prefix is not lib.no_default
):
raise ValueError("Specified named and prefix; you can only specify one.")

kwds["names"] = None if names is lib.no_default else names
Expand Down
17 changes: 13 additions & 4 deletions pandas/tests/io/parser/common/test_common_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,15 +764,24 @@ def test_read_table_delim_whitespace_non_default_sep(all_parsers, delimiter):


@pytest.mark.parametrize("func", ["read_csv", "read_table"])
@pytest.mark.parametrize("prefix", [None, "x"])
@pytest.mark.parametrize("names", [None, ["a"]])
def test_names_and_prefix_not_lib_no_default(all_parsers, names, prefix, func):
def test_names_and_prefix_not_None_raises(all_parsers, func):
# GH#39123
f = StringIO("a,b\n1,2")
parser = all_parsers
msg = "Specified named and prefix; you can only specify one."
with pytest.raises(ValueError, match=msg):
getattr(parser, func)(f, names=names, prefix=prefix)
getattr(parser, func)(f, names=["a", "b"], prefix="x")


@pytest.mark.parametrize("func", ["read_csv", "read_table"])
@pytest.mark.parametrize("prefix, names", [(None, ["x0", "x1"]), ("x", None)])
def test_names_and_prefix_explicit_None(all_parsers, names, prefix, func):
# GH42387
f = StringIO("a,b\n1,2")
expected = DataFrame({"x0": ["a", "1"], "x1": ["b", "2"]})
parser = all_parsers
result = getattr(parser, func)(f, names=names, sep=",", prefix=prefix, header=None)
tm.assert_frame_equal(result, expected)


def test_dict_keys_as_names(all_parsers):
Expand Down