Skip to main content

Apply each value in a column against the whole column

Project description

Apply each value in a column against the whole column

pip install a-pandas-ex-apply-against-all
from a_pandas_ex_apply_against_all import pd_add_apply_each

import pandas as pd

pd_add_apply_each()

df = pd.read_csv(

    "https://raw.githubusercontent.com/pandas-dev/pandas/main/doc/data/titanic.csv"

)

df1 = df.PassengerId.s_apply_each(

    expression="str(x) + str(y)", # use always x/y in your expression

    exception_value=pd.NA,

    diagonal_value=pd.NA,

    print_exception=True,

)

print(df1)

      0     1     2     3     4    ...     886     887     888     889     890

0    <NA>    12    13    14    15  ...    1887    1888    1889    1890    1891

1      21  <NA>    23    24    25  ...    2887    2888    2889    2890    2891

2      31    32  <NA>    34    35  ...    3887    3888    3889    3890    3891

3      41    42    43  <NA>    45  ...    4887    4888    4889    4890    4891

4      51    52    53    54  <NA>  ...    5887    5888    5889    5890    5891

..    ...   ...   ...   ...   ...  ...     ...     ...     ...     ...     ...

886  8871  8872  8873  8874  8875  ...    <NA>  887888  887889  887890  887891

887  8881  8882  8883  8884  8885  ...  888887    <NA>  888889  888890  888891

888  8891  8892  8893  8894  8895  ...  889887  889888    <NA>  889890  889891

889  8901  8902  8903  8904  8905  ...  890887  890888  890889    <NA>  890891

890  8911  8912  8913  8914  8915  ...  891887  891888  891889  891890    <NA>

[891 rows x 891 columns]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

a_pandas_ex_apply_against_all-0.10.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file a_pandas_ex_apply_against_all-0.10.tar.gz.

File metadata

File hashes

Hashes for a_pandas_ex_apply_against_all-0.10.tar.gz
Algorithm Hash digest
SHA256 62522f27923be0c416076ca85b95ea18ea28ac2a09b508a1e8f77a9ec99a858e
MD5 f9204f86e762d87f49e00a913eb22554
BLAKE2b-256 31c6c9f1ca83200f0db087519ae1368f5b705faafe20f92b483acb078eb6d5d8

See more details on using hashes here.

Provenance

File details

Details for the file a_pandas_ex_apply_against_all-0.10-py3-none-any.whl.

File metadata

File hashes

Hashes for a_pandas_ex_apply_against_all-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 b62c917cd78c21c2cb08897fb3f5e1da083755126bcca90b790009e83400141c
MD5 a97c750f204a1011d2783ead6d723657
BLAKE2b-256 c86060b8849857c784c41bda2642d50a6cbd09cc25958fd928c08660cc2dd23e

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page