Skip to content

Calling drop_duplicates method for empty pandas dataframe throws error #20516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
analyticalmonk opened this issue Mar 28, 2018 · 4 comments · Fixed by #22394
Closed

Calling drop_duplicates method for empty pandas dataframe throws error #20516

analyticalmonk opened this issue Mar 28, 2018 · 4 comments · Fixed by #22394
Labels
Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Milestone

Comments

@analyticalmonk
Copy link
Contributor

Code Sample

>>> pd.DataFrame().drop_duplicates()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/analytical-monk/miniconda3/lib/python3.6/site-packages/pandas/core/frame.py", line 3098, in drop_duplicates
    duplicated = self.duplicated(subset, keep=keep)
  File "/home/analytical-monk/miniconda3/lib/python3.6/site-packages/pandas/core/frame.py", line 3144, in duplicated
    labels, shape = map(list, zip(*map(f, vals)))
ValueError: not enough values to unpack (expected 2, got 0)

Problem description

Currently, calling the drop_duplicates method for an empty dataframe object (simply pd.DataFrame()) throws an error.
Ideally it should return back the empty dataframe just liked it does when at least one column is present.

Expected Output

>>> pd.DataFrame().drop_duplicates()

Empty DataFrame
Columns: []
Index: []

Output of pd.show_versions()

>>> pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 3.6.1.final.0
python-bits: 64
OS: Linux
OS-release: 4.8.0-58-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_IN
LOCALE: en_IN.ISO8859-1

pandas: 0.20.3
pytest: None
pip: 9.0.1
setuptools: 36.6.0
Cython: None
numpy: 1.13.1
scipy: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.6.0
html5lib: 1.0b10
sqlalchemy: 1.1.14
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
pandas_gbq: None
pandas_datareader: None
@analyticalmonk
Copy link
Contributor Author

@TomAugspurger Opened this issue for the problem I'd mentioned in the gitter chat.

@arpit1997
Copy link

Can I work on this issue? @TomAugspurger

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Mar 28, 2018 via email

@jreback jreback added Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode Difficulty Intermediate labels Mar 29, 2018
@jreback jreback added this to the Next Major Release milestone Mar 29, 2018
@minggli
Copy link
Contributor

minggli commented May 2, 2018

@arpit1997 are you still working on this?

@jreback jreback modified the milestones: Next Major Release, 0.23.0, 0.23.1 May 8, 2018
@jreback jreback modified the milestones: 0.23.1, 0.23.2 Jun 7, 2018
@jreback jreback modified the milestones: 0.23.2, 0.23.3 Jun 26, 2018
@jreback jreback modified the milestones: 0.23.4, 0.24.0, Contributions Welcome Aug 2, 2018
@jreback jreback modified the milestones: Contributions Welcome, 0.24.0 Aug 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
5 participants