Skip to main content

Find the lower and upper neighbours in a pandas.Series

pip install a-pandas-ex-closest-neighbours
    Usage:



from a_pandas_ex_closest_neighbours import pd_add_closest_neighbours

import pandas as pd

from random import choice  # random dataframe

pd_add_closest_neighbours()

sizes = list(range(1, 100))

df = pd.DataFrame([choice(sizes) for x in range(1000)])

df.columns = ['num']







    df

Out[3]:

     num

0     17

1     32

2     17

3     90

4     76

..   ...

995   69

996   82

997   65

998   84

999   62

[1000 rows x 1 columns]





min_neighbours2, max_neighbours2 = df.num.s_find_closest_neighbours(value=72, convertdtypes=True,

                                                   accept_exact_match=False)

min_neighbours2

Out[8]:

    lower_index  lower_value

0            95           71

1           184           71

2           265           71

3           291           71

4           486           71

5           569           71

6           644           71

7           652           71

8           742           71

9           804           71

10          830           71

11          964           71



max_neighbours2

Out[9]:

    upper_index  upper_value

0            26           73

1            44           73

2           119           73

3           161           73

4           219           73

5           397           73

6           415           73

7           492           73

8           593           73

9           610           73

10          612           73

11          802           73















min_neighbours2, max_neighbours2 = df.num.s_find_closest_neighbours(value=72, convertdtypes=True,

                                                   accept_exact_match=True)



max_neighbours1

Out[4]:

    upper_index  upper_value

0           105           72

1           147           72

2           210           72

3           281           72

4           317           72

5           361           72

6           377           72

7           386           72

8           485           72

9           521           72

10          675           72

11          956           72

12          957           72

min_neighbours1



Out[5]:

    lower_index  lower_value

0           105           72

1           147           72

2           210           72

3           281           72

4           317           72

5           361           72

6           377           72

7           386           72

8           485           72

9           521           72

10          675           72

11          956           72

12          957           72





    Parameters:

        series:pd.Series

            Only pandas.Series

        value:Union[float,int]

            the value you want to have the closest neighbours from

        convertdtypes:bool

            converts string numbers to numbers

            (default=False)

        accept_exact_match:bool

            example:

            True: if you are passing 72, and 72 is in the Series, the minimum and maximum values will be all the same, that means: 72

            False: All cells with 72 are excluded, and you won't see 72 in the results

            (default=False)

    Returns:

        tuple

Metadata

Release files for a-pandas-ex-closest-neighbours 0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for a-pandas-ex-closest-neighbours 0.10
File Size Uploaded Provenance Actions
a_pandas_ex_closest_neighbours-0.10.tar.gz 5.6 kB Without provenance Details for a_pandas_ex_closest_neighbours-0.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for a-pandas-ex-closest-neighbours 0.10
File Interpreter ABI Platform Actions
a_pandas_ex_closest_neighbours-0.10-py3-none-any.whl Python 3 none any Details for a_pandas_ex_closest_neighbours-0.10-py3-none-any.whl

Total release size: 13.2 kB

Release files / a_pandas_ex_closest_neighbours-0.10.tar.gz

Download URL a_pandas_ex_closest_neighbours-0.10.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f11987ead5a093f12f95a0d849f25678100fc3c156dd414864fda589c8604b4b
BLAKE2b-256 checksum
How to use checksums
451956818d1cba9ff52fc7aed568be8dfac213124bc24ba55efb86fd2ccb6186
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / a_pandas_ex_closest_neighbours-0.10-py3-none-any.whl

Download URL a_pandas_ex_closest_neighbours-0.10-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
31b49faec214708370d3d23bddf069bc08a84f34abd3edec872aff1b9104f4fe
BLAKE2b-256 checksum
How to use checksums
b14c06586721d4cb7dc94f1bfd0eeea6f988ec063f04191dc140259d0123a773
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Security for a-pandas-ex-closest-neighbours 0.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.10 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page