Skip to content
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

Should pd.core.algorithms.match have been removed? #31827

Closed
rwolst opened this issue Feb 9, 2020 · 3 comments
Closed

Should pd.core.algorithms.match have been removed? #31827

rwolst opened this issue Feb 9, 2020 · 3 comments
Labels
Regression Functionality that used to work in a prior pandas version

Comments

@rwolst
Copy link

rwolst commented Feb 9, 2020

Code Sample, a copy-pastable example if possible

import pandas

pandas.core.algorithms.match

Problem description

I have just started using the 1.0 release and just realised that the pandas.core.algorithms.match function has been removed. I did some investigating and found it was first discussed here

#15538

and then finally removed here

#29249

I was often using this function and found it very useful. I'm not sure why it was removed (if there is a better way to do what it is doing I would love to know), otherwise in the first link @jorisvandenbossche said

"If someone uses it, sees the removal message, they can always complain that it was useful and we can think about how to publicly expose it (I don't think core.algorithms should be that place)."

so this is me complaining and saying it was useful.

Expected Output

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]

pd.show_versions()

INSTALLED VERSIONS

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

pandas : 1.0.1
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 20.0.2
setuptools : 45.2.0
Cython : None
pytest : 5.3.5
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : 5.3.5
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
numba : None

@MarcoGorelli MarcoGorelli added the Regression Functionality that used to work in a prior pandas version label Feb 13, 2020
@jbrockmendel
Copy link
Member

Thank you for letting us know.

To help you find an alternative, can you tell us what dtypes you are working with, and how big the to_match and values arrays you work with are (ballpark)?

@jbrockmendel
Copy link
Member

Discussed briefly in #32415 and the answer appears to be "yes". Closing, can re-open if you want to discuss alternatives (see question from my previous comment)

@rwolst
Copy link
Author

rwolst commented Mar 24, 2020

I think this is fine to close, essentially the work arounds are:

  1. Use the code from an old version of pandas in the project you are working on (i.e. from https://github.com/pandas-dev/pandas/blob/0.22.x/pandas/core/algorithms.py#L238).

  2. Can also be accomplished with a merge, although slightly uglier:

to_match = [2, 4, 5]
values = [1, 2, -1, 4]
na_sentinal = -1

matches = pd.DataFrame(values, columns=['X']).reset_index().merge(
    pd.DataFrame(to_match, columns=['X']),
    how='right'
)['index'].fillna(na_sentinal).astype('int64')

Also should be careful of some potential rounding/casting errors.

@simonjayhawkins simonjayhawkins added this to the No action milestone May 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

No branches or pull requests

4 participants