A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/46653 below:

add validation checks on levels keyword from pd.concat · Issue #46653 · pandas-dev/pandas · GitHub

Pandas version checks Reproducible Example
>>> df1 = pd.DataFrame({"A": [1]}, index=["x"])
>>> df2 = pd.DataFrame({"A": [1]}, index=["y"])
>>> pd.concat([df1, df2], keys=["x", "y"], levels=[["x", "y", "y"]])
     A
x x  1
y y  1


```python
>>> df1 = pd.DataFrame({"A": [1]}, index=["x"])
>>> df2 = pd.DataFrame({"A": [1]}, index=["y"])
>>> pd.concat([df1, df2], levels=[["x", "y"]])
   A
x  1
y  1
Issue Description

First, we should raise when levels duplicated. Second, when levels specified and keys not given, then we should also raise since this is unreasonable. (DOC only mentions infering levels from keys but not infering keys from levels)

Expected Behavior
>>> df1 = pd.DataFrame({"A": [1]}, index=["x"])
>>> df2 = pd.DataFrame({"A": [1]}, index=["y"])
>>> pd.concat([df1, df2], keys=["x", "y"], levels=[["x", "y", "y"]])
ValueError: Level values not unique: ['x', 'y', 'y']
>>> df1 = pd.DataFrame({"A": [1]}, index=["x"])
>>> df2 = pd.DataFrame({"A": [1]}, index=["y"])
>>> pd.concat([df1, df2], levels=[["x", "y"]])
ValueError: levels supported only when keys not None
Installed Versions

1.4.1


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4