Skip to main content

Split a Pandas.Series on a common string

Project description

$pip install a-pandas-ex-split-on-common-string

from a_pandas_ex_split_on_common_string import pd_add_split_on_common_string

pd_add_split_on_common_string()

df = pd.read_csv("https://raw.githubusercontent.com/pandas-dev/pandas/main/doc/data/titanic.csv")

df['text'] = 'myway_/bo' + df.Embarked.astype('string') + '.txt'

print(df.text.s_split_on_common_string(is_path=False))

print(df.text.s_split_on_common_string(is_path=True))



		aa_original  aa_common aa_different

0    myway_/boS.txt  myway_/bo        S.txt

1    myway_/boC.txt  myway_/bo        C.txt

2    myway_/boS.txt  myway_/bo        S.txt

3    myway_/boS.txt  myway_/bo        S.txt

4    myway_/boS.txt  myway_/bo        S.txt

..              ...        ...          ...

886  myway_/boS.txt  myway_/bo        S.txt

887  myway_/boS.txt  myway_/bo        S.txt

888  myway_/boS.txt  myway_/bo        S.txt

889  myway_/boC.txt  myway_/bo        C.txt

890  myway_/boQ.txt  myway_/bo        Q.txt

[891 rows x 3 columns]

		aa_original aa_common aa_different

0    myway_/boS.txt    myway_     /boS.txt

1    myway_/boC.txt    myway_     /boC.txt

2    myway_/boS.txt    myway_     /boS.txt

3    myway_/boS.txt    myway_     /boS.txt

4    myway_/boS.txt    myway_     /boS.txt

..              ...       ...          ...

886  myway_/boS.txt    myway_     /boS.txt

887  myway_/boS.txt    myway_     /boS.txt

888  myway_/boS.txt    myway_     /boS.txt

889  myway_/boC.txt    myway_     /boC.txt

890  myway_/boQ.txt    myway_     /boQ.txt

[891 rows x 3 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

Built Distribution

File details

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

File metadata

File hashes

Hashes for a_pandas_ex_split_on_common_string-0.10.tar.gz
Algorithm Hash digest
SHA256 00b987dc94293de9ddfb6dc0cb1165716f9d73997fb57eb7c19674cedb8be90a
MD5 704d530d8fd7056ba231e06c9ad3df4b
BLAKE2b-256 2c05b0dc28d2f28dce7677c2bcd7090085742654dba4f68e912bc7c655db68c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for a_pandas_ex_split_on_common_string-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 13ae56ed187a6bdb0d5a4d55dfd51fb67d05f1c9a01b942643133c2ff9965e7f
MD5 548e71c8fa076b1363abf8973d554024
BLAKE2b-256 178e41baffa099ff15ae4f6e1d857eaf5bc06dddc8adf43b38cc7a474cb6afb3

See more details on using hashes here.

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