Skip to content

Explode on identical index causes duplication #28005

Closed
@mar-muel

Description

@mar-muel

Code Sample, a copy-pastable example if possible

>>> df = pd.DataFrame({'col': [['a', 'b'], ['c', 'd']]}, index=[0,0])
>>> df.explode('col')
  col
0   a
0   b
0   c
0   d
0   a
0   b
0   c
0   d

Problem description

I'm not sure if this is expected behaviour. But it took me slightly off guard when I had a datetime index with occasionally identical timestamps. This is the output I expected:

  col
0   a
0   b
0   c
0   d

Thanks for your work on pandas! Apologies if this is actually normal behaviour.

Output of pd.show_versions()

INSTALLED VERSIONS

commit : None
python : 3.6.7.final.0
python-bits : 64
OS : Linux
OS-release : 4.4.0-139-generic
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : en_US.UTF-8
LANG : en_US
LOCALE : en_US.UTF-8

pandas : 0.25.0
numpy : 1.14.3
pytz : 2018.9
dateutil : 2.8.0
pip : 19.0.2
setuptools : 40.8.0
Cython : None
pytest : 4.5.0
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.10
IPython : 7.3.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : 3.0.2
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : 1.2.1
sqlalchemy : None
tables : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions