Parameters:
-----------
self : Series
The input Series containing strings to be split.
sepstring : str, optional
The separator string to split the elements by (default is a single space).
len_tolerance : int, optional
Minimum length of resulting strings to be considered valid (default is 0).
Returns:
--------
pandas.DataFrame
A DataFrame containing the split elements from the Series.
stringtosplit = '''
unix 2 [ ] DGRAM 13449 - /data/system/unsolzygotesocket
unix 2 [ ACC ] STREAM LISTENING 13019 - /data/system/ndebugsocket
unix 2 [ ACC ] STREAM LISTENING 13104 - @com.android.internal.os.WebViewZygoteInit/58dbfcdc-c54c-4201-81c2-9cc331e5aff8
unix 2 [ ACC ] STREAM LISTENING 20451 - @com.android.internal.os.AppZygoteInit/2da63555-2b8e-4593-b42c-6386b4d36f59
unix 2 [ ACC ] STREAM LISTENING 8276 - /dev/socket/property_service
unix 2 [ ACC ] STREAM LISTENING 8556 - /dev/socket/logd
unix 2 [ ACC ] SEQPACKET LISTENING 8558 - /dev/socket/logdr
unix 83 [ ] DGRAM 8560 - /dev/socket/logdw
unix 2 [ ACC ] SEQPACKET LISTENING 8563 - /dev/socket/lmkd
unix 2 [ ACC ] SEQPACKET LISTENING 8838 - /dev/socket/tombstoned_crash
unix 2 [ ACC ] SEQPACKET LISTENING 8840 - /dev/socket/tombstoned_intercept
unix 2 [ ACC ] SEQPACKET LISTENING 8842 - /dev/socket/tombstoned_java_trace
unix 22 [ ] DGRAM 8889 - /dev/socket/statsdw
unix 2 [ ACC ] STREAM LISTENING 8892 - /dev/socket/dnsproxyd
unix 2 [ ACC ] STREAM LISTENING 8894 - /dev/socket/mdns
unix 2 [ ACC ] STREAM LISTENING 8896 - /dev/socket/fwmarkd
unix 2 [ ACC ] STREAM LISTENING 8899 - /dev/socket/zygote
unix 2 [ ACC ] STREAM LISTENING 8901 - /dev/socket/usap_pool_primary
unix 2 [ ACC ] STREAM LISTENING 8904 - /dev/socket/zygote_secondary
unix 2 [ ACC ] STREAM LISTENING 8906 - /dev/socket/usap_pool_secondary
unix 2 [ ACC ] STREAM LISTENING 9937 - /dev/socket/mdnsd
unix 2 [ ACC ] STREAM LISTENING 9941 - /dev/socket/traced_consumer
unix 2 [ ACC ] STREAM LISTENING 9943 - /dev/socket/traced_producer
unix 2 [ ACC ] SEQPACKET LISTENING 10879 - @jdwp-control
unix 2 [ ACC ] SEQPACKET LISTENING 10488 - /dev/socket/adbd
unix 2 [ ] DGRAM 21149 -
unix 3 [ ] STREAM CONNECTED 12840 - /dev/socket/zygote
unix 3 [ ] STREAM CONNECTED 20457 - @com.android.internal.os.AppZygoteInit/2da63555-2b8e-4593-b42c-6386b4d36f59
unix 3 [ ] SEQPACKET CONNECTED 21156 -
unix 3 [ ] SEQPACKET CONNECTED 16570 -
unix 2 [ ] DGRAM 13698 -
unix 3 [ ] SEQPACKET CONNECTED 13012 - @jdwp-control
unix 2 [ ] DGRAM 11680 -
unix 3 [ ] SEQPACKET CONNECTED 25569 -
unix 3 [ ] SEQPACKET CONNECTED 25208 -
unix 3 [ ] STREAM CONNECTED 20456 -
unix 2 [ ] DGRAM 16746 -
unix 3 [ ] STREAM CONNECTED 39851 -
unix 2 [ ] DGRAM 11550 -
unix 2 [ ] DGRAM 9804 -
unix 2 [ ] DGRAM 10301 -
unix 3 [ ] SEQPACKET CONNECTED 27528 -
unix 3 [ ] SEQPACKET CONNECTED 20653 -
unix 2 [ ] DGRAM 8075 -
unix 2 [ ] DGRAM 10131 -
unix 3 [ ] SEQPACKET CONNECTED 16077 -
unix 3 [ ] SEQPACKET CONNECTED 15948 -
unix 3 [ ] SEQPACKET CONNECTED 12462 - /dev/socket/logdr
unix 3 [ ] SEQPACKET CONNECTED 35988 -
unix 2 [ ] DGRAM 11571 -
unix 3 [ ] SEQPACKET CONNECTED 16759 -
unix 3 [ ] SEQPACKET CONNECTED 13514 -
unix 2 [ ] DGRAM 26323 -
unix 3 [ ] STREAM CONNECTED 19740 -
unix 3 [ ] SEQPACKET CONNECTED 19600 - @jdwp-control
unix 3 [ ] STREAM CONNECTED 9918 -
unix 3 [ ] SEQPACKET CONNECTED 16585 - @jdwp-control
unix 3 [ ] SEQPACKET CONNECTED 11710 -
'''
from a_pandas_ex_split_on_common_char import pd_add_split_on_common_char
pd_add_split_on_common_char()
df = pd.DataFrame(stringtosplit.strip().splitlines())
df2 = df[0].s_split_on_common_char(sepstring=" ", len_tolerance=0)
df3 = df[0].s_split_on_common_char(sepstring="[", len_tolerance=0)
df4 = df[0].s_split_on_common_char(sepstring="]", len_tolerance=25)
# df
# Out[6]:
# 0
# 0 unix 2 [ ] DGRAM ...
# 1 unix 2 [ ACC ] STREAM LISTENING ...
# 2 unix 2 [ ACC ] STREAM LISTENING ...
# 3 unix 2 [ ACC ] STREAM LISTENING ...
# 4 unix 2 [ ACC ] STREAM LISTENING ...
# 5 unix 2 [ ACC ] STREAM LISTENING ...
# 6 unix 2 [ ACC ] SEQPACKET LISTENING ...
# 7 unix 83 [ ] DGRAM ...
# 8 unix 2 [ ACC ] SEQPACKET LISTENING ...
# 9 unix 2 [ ACC ] SEQPACKET LISTENING ...
# 10 unix 2 [ ACC ] SEQPACKET LISTENING ...
# 11 unix 2 [ ACC ] SEQPACKET LISTENING ...
# 12 unix 22 [ ] DGRAM ...
# 13 unix 2 [ ACC ] STREAM LISTENING ...
# 14 unix 2 [ ACC ] STREAM LISTENING ...
# 15 unix 2 [ ACC ] STREAM LISTENING ...
# 16 unix 2 [ ACC ] STREAM LISTENING ...
# 17 unix 2 [ ACC ] STREAM LISTENING ...
# 18 unix 2 [ ACC ] STREAM LISTENING ...
# 19 unix 2 [ ACC ] STREAM LISTENING ...
# 20 unix 2 [ ACC ] STREAM LISTENING ...
# 21 unix 2 [ ACC ] STREAM LISTENING ...
# 22 unix 2 [ ACC ] STREAM LISTENING ...
# 23 unix 2 [ ACC ] SEQPACKET LISTENING ...
# 24 unix 2 [ ACC ] SEQPACKET LISTENING ...
# 25 unix 2 [ ] DGRAM ...
# 26 unix 3 [ ] STREAM CONNECTED ...
# 27 unix 3 [ ] STREAM CONNECTED ...
# 28 unix 3 [ ] SEQPACKET CONNECTED ...
# 29 unix 3 [ ] SEQPACKET CONNECTED ...
# 30 unix 2 [ ] DGRAM ...
# 31 unix 3 [ ] SEQPACKET CONNECTED ...
# 32 unix 2 [ ] DGRAM ...
# 33 unix 3 [ ] SEQPACKET CONNECTED ...
# 34 unix 3 [ ] SEQPACKET CONNECTED ...
# 35 unix 3 [ ] STREAM CONNECTED ...
# 36 unix 2 [ ] DGRAM ...
# 37 unix 3 [ ] STREAM CONNECTED ...
# 38 unix 2 [ ] DGRAM ...
# 39 unix 2 [ ] DGRAM ...
# 40 unix 2 [ ] DGRAM ...
# 41 unix 3 [ ] SEQPACKET CONNECTED ...
# 42 unix 3 [ ] SEQPACKET CONNECTED ...
# 43 unix 2 [ ] DGRAM ...
# 44 unix 2 [ ] DGRAM ...
# 45 unix 3 [ ] SEQPACKET CONNECTED ...
# 46 unix 3 [ ] SEQPACKET CONNECTED ...
# 47 unix 3 [ ] SEQPACKET CONNECTED ...
# 48 unix 3 [ ] SEQPACKET CONNECTED ...
# 49 unix 2 [ ] DGRAM ...
# 50 unix 3 [ ] SEQPACKET CONNECTED ...
# 51 unix 3 [ ] SEQPACKET CONNECTED ...
# 52 unix 2 [ ] DGRAM ...
# 53 unix 3 [ ] STREAM CONNECTED ...
# 54 unix 3 [ ] SEQPACKET CONNECTED ...
# 55 unix 3 [ ] STREAM CONNECTED ...
# 56 unix 3 [ ] SEQPACKET CONNECTED ...
# 57 unix 3 [ ] SEQPACKET CONNECTED ...
# df2
# Out[7]:
# 0 1 2 ... 7 8 9
# 0 unix 2 [ ... 13449 - /data/system/unsolzygotesocket
# 1 unix 2 [ ... 13019 - /data/system/ndebugsocket
# 2 unix 2 [ ... 13104 - @com.android.internal.os.WebVi
# 3 unix 2 [ ... 20451 - @com.android.internal.os.AppZy
# 4 unix 2 [ ... 8276 - /dev/socket/property_service
# 5 unix 2 [ ... 8556 - /dev/socket/logd
# 6 unix 2 [ ... 8558 - /dev/socket/logdr
# 7 unix 83 [ ... 8560 - /dev/socket/logdw
# 8 unix 2 [ ... 8563 - /dev/socket/lmkd
# 9 unix 2 [ ... 8838 - /dev/socket/tombstoned_crash
# 10 unix 2 [ ... 8840 - /dev/socket/tombstoned_interce
# 11 unix 2 [ ... 8842 - /dev/socket/tombstoned_java_tr
# 12 unix 22 [ ... 8889 - /dev/socket/statsdw
# 13 unix 2 [ ... 8892 - /dev/socket/dnsproxyd
# 14 unix 2 [ ... 8894 - /dev/socket/mdns
# 15 unix 2 [ ... 8896 - /dev/socket/fwmarkd
# 16 unix 2 [ ... 8899 - /dev/socket/zygote
# 17 unix 2 [ ... 8901 - /dev/socket/usap_pool_primary
# 18 unix 2 [ ... 8904 - /dev/socket/zygote_secondary
# 19 unix 2 [ ... 8906 - /dev/socket/usap_pool_secondar
# 20 unix 2 [ ... 9937 - /dev/socket/mdnsd
# 21 unix 2 [ ... 9941 - /dev/socket/traced_consumer
# 22 unix 2 [ ... 9943 - /dev/socket/traced_producer
# 23 unix 2 [ ... 10879 - @jdwp-control
# 24 unix 2 [ ... 10488 - /dev/socket/adbd
# 25 unix 2 [ ... 21149 -
# 26 unix 3 [ ... 12840 - /dev/socket/zygote
# 27 unix 3 [ ... 20457 - @com.android.internal.os.AppZy
# 28 unix 3 [ ... 21156 -
# 29 unix 3 [ ... 16570 -
# 30 unix 2 [ ... 13698 -
# 31 unix 3 [ ... 13012 - @jdwp-control
# 32 unix 2 [ ... 11680 -
# 33 unix 3 [ ... 25569 -
# 34 unix 3 [ ... 25208 -
# 35 unix 3 [ ... 20456 -
# 36 unix 2 [ ... 16746 -
# 37 unix 3 [ ... 39851 -
# 38 unix 2 [ ... 11550 -
# 39 unix 2 [ ... 9804 -
# 40 unix 2 [ ... 10301 -
# 41 unix 3 [ ... 27528 -
# 42 unix 3 [ ... 20653 -
# 43 unix 2 [ ... 8075 -
# 44 unix 2 [ ... 10131 -
# 45 unix 3 [ ... 16077 -
# 46 unix 3 [ ... 15948 -
# 47 unix 3 [ ... 12462 - /dev/socket/logdr
# 48 unix 3 [ ... 35988 -
# 49 unix 2 [ ... 11571 -
# 50 unix 3 [ ... 16759 -
# 51 unix 3 [ ... 13514 -
# 52 unix 2 [ ... 26323 -
# 53 unix 3 [ ... 19740 -
# 54 unix 3 [ ... 19600 - @jdwp-control
# 55 unix 3 [ ... 9918 -
# 56 unix 3 [ ... 16585 - @jdwp-control
# 57 unix 3 [ ... 11710 -
# [58 rows x 10 columns]
# df3
# Out[8]:
# 0 1
# 0 unix 2 [ ] DGRAM 13449 ...
# 1 unix 2 [ ACC ] STREAM LISTENING 13019 ...
# 2 unix 2 [ ACC ] STREAM LISTENING 13104 ...
# 3 unix 2 [ ACC ] STREAM LISTENING 20451 ...
# 4 unix 2 [ ACC ] STREAM LISTENING 8276 ...
# 5 unix 2 [ ACC ] STREAM LISTENING 8556 ...
# 6 unix 2 [ ACC ] SEQPACKET LISTENING 8558 ...
# 7 unix 83 [ ] DGRAM 8560 ...
# 8 unix 2 [ ACC ] SEQPACKET LISTENING 8563 ...
# 9 unix 2 [ ACC ] SEQPACKET LISTENING 8838 ...
# 10 unix 2 [ ACC ] SEQPACKET LISTENING 8840 ...
# 11 unix 2 [ ACC ] SEQPACKET LISTENING 8842 ...
# 12 unix 22 [ ] DGRAM 8889 ...
# 13 unix 2 [ ACC ] STREAM LISTENING 8892 ...
# 14 unix 2 [ ACC ] STREAM LISTENING 8894 ...
# 15 unix 2 [ ACC ] STREAM LISTENING 8896 ...
# 16 unix 2 [ ACC ] STREAM LISTENING 8899 ...
# 17 unix 2 [ ACC ] STREAM LISTENING 8901 ...
# 18 unix 2 [ ACC ] STREAM LISTENING 8904 ...
# 19 unix 2 [ ACC ] STREAM LISTENING 8906 ...
# 20 unix 2 [ ACC ] STREAM LISTENING 9937 ...
# 21 unix 2 [ ACC ] STREAM LISTENING 9941 ...
# 22 unix 2 [ ACC ] STREAM LISTENING 9943 ...
# 23 unix 2 [ ACC ] SEQPACKET LISTENING 10879 ...
# 24 unix 2 [ ACC ] SEQPACKET LISTENING 10488 ...
# 25 unix 2 [ ] DGRAM 21149 ...
# 26 unix 3 [ ] STREAM CONNECTED 12840 ...
# 27 unix 3 [ ] STREAM CONNECTED 20457 ...
# 28 unix 3 [ ] SEQPACKET CONNECTED 21156 ...
# 29 unix 3 [ ] SEQPACKET CONNECTED 16570 ...
# 30 unix 2 [ ] DGRAM 13698 ...
# 31 unix 3 [ ] SEQPACKET CONNECTED 13012 ...
# 32 unix 2 [ ] DGRAM 11680 ...
# 33 unix 3 [ ] SEQPACKET CONNECTED 25569 ...
# 34 unix 3 [ ] SEQPACKET CONNECTED 25208 ...
# 35 unix 3 [ ] STREAM CONNECTED 20456 ...
# 36 unix 2 [ ] DGRAM 16746 ...
# 37 unix 3 [ ] STREAM CONNECTED 39851 ...
# 38 unix 2 [ ] DGRAM 11550 ...
# 39 unix 2 [ ] DGRAM 9804 ...
# 40 unix 2 [ ] DGRAM 10301 ...
# 41 unix 3 [ ] SEQPACKET CONNECTED 27528 ...
# 42 unix 3 [ ] SEQPACKET CONNECTED 20653 ...
# 43 unix 2 [ ] DGRAM 8075 ...
# 44 unix 2 [ ] DGRAM 10131 ...
# 45 unix 3 [ ] SEQPACKET CONNECTED 16077 ...
# 46 unix 3 [ ] SEQPACKET CONNECTED 15948 ...
# 47 unix 3 [ ] SEQPACKET CONNECTED 12462 ...
# 48 unix 3 [ ] SEQPACKET CONNECTED 35988 ...
# 49 unix 2 [ ] DGRAM 11571 ...
# 50 unix 3 [ ] SEQPACKET CONNECTED 16759 ...
# 51 unix 3 [ ] SEQPACKET CONNECTED 13514 ...
# 52 unix 2 [ ] DGRAM 26323 ...
# 53 unix 3 [ ] STREAM CONNECTED 19740 ...
# 54 unix 3 [ ] SEQPACKET CONNECTED 19600 ...
# 55 unix 3 [ ] STREAM CONNECTED 9918 ...
# 56 unix 3 [ ] SEQPACKET CONNECTED 16585 ...
# 57 unix 3 [ ] SEQPACKET CONNECTED 11710 -
# df4
# Out[9]:
# 0 1
# 0 unix 2 [ ] DGRAM 13449 - ...
# 1 unix 2 [ ACC ] STREAM LISTENING 13019 - ...
# 2 unix 2 [ ACC ] STREAM LISTENING 13104 - ...
# 3 unix 2 [ ACC ] STREAM LISTENING 20451 - ...
# 4 unix 2 [ ACC ] STREAM LISTENING 8276 - ...
# 5 unix 2 [ ACC ] STREAM LISTENING 8556 - ...
# 6 unix 2 [ ACC ] SEQPACKET LISTENING 8558 - ...
# 7 unix 83 [ ] DGRAM 8560 - ...
# 8 unix 2 [ ACC ] SEQPACKET LISTENING 8563 - ...
# 9 unix 2 [ ACC ] SEQPACKET LISTENING 8838 - ...
# 10 unix 2 [ ACC ] SEQPACKET LISTENING 8840 - ...
# 11 unix 2 [ ACC ] SEQPACKET LISTENING 8842 - ...
# 12 unix 22 [ ] DGRAM 8889 - ...
# 13 unix 2 [ ACC ] STREAM LISTENING 8892 - ...
# 14 unix 2 [ ACC ] STREAM LISTENING 8894 - ...
# 15 unix 2 [ ACC ] STREAM LISTENING 8896 - ...
# 16 unix 2 [ ACC ] STREAM LISTENING 8899 - ...
# 17 unix 2 [ ACC ] STREAM LISTENING 8901 - ...
# 18 unix 2 [ ACC ] STREAM LISTENING 8904 - ...
# 19 unix 2 [ ACC ] STREAM LISTENING 8906 - ...
# 20 unix 2 [ ACC ] STREAM LISTENING 9937 - ...
# 21 unix 2 [ ACC ] STREAM LISTENING 9941 - ...
# 22 unix 2 [ ACC ] STREAM LISTENING 9943 - ...
# 23 unix 2 [ ACC ] SEQPACKET LISTENING 10879 - ...
# 24 unix 2 [ ACC ] SEQPACKET LISTENING 10488 - ...
# 25 unix 2 [ ] DGRAM 21149 - ...
# 26 unix 3 [ ] STREAM CONNECTED 12840 - ...
# 27 unix 3 [ ] STREAM CONNECTED 20457 - ...
# 28 unix 3 [ ] SEQPACKET CONNECTED 21156 - ...
# 29 unix 3 [ ] SEQPACKET CONNECTED 16570 - ...
# 30 unix 2 [ ] DGRAM 13698 - ...
# 31 unix 3 [ ] SEQPACKET CONNECTED 13012 - ...
# 32 unix 2 [ ] DGRAM 11680 - ...
# 33 unix 3 [ ] SEQPACKET CONNECTED 25569 - ...
# 34 unix 3 [ ] SEQPACKET CONNECTED 25208 - ...
# 35 unix 3 [ ] STREAM CONNECTED 20456 - ...
# 36 unix 2 [ ] DGRAM 16746 - ...
# 37 unix 3 [ ] STREAM CONNECTED 39851 - ...
# 38 unix 2 [ ] DGRAM 11550 - ...
# 39 unix 2 [ ] DGRAM 9804 - ...
# 40 unix 2 [ ] DGRAM 10301 - ...
# 41 unix 3 [ ] SEQPACKET CONNECTED 27528 - ...
# 42 unix 3 [ ] SEQPACKET CONNECTED 20653 - ...
# 43 unix 2 [ ] DGRAM 8075 - ...
# 44 unix 2 [ ] DGRAM 10131 - ...
# 45 unix 3 [ ] SEQPACKET CONNECTED 16077 - ...
# 46 unix 3 [ ] SEQPACKET CONNECTED 15948 - ...
# 47 unix 3 [ ] SEQPACKET CONNECTED 12462 - ...
# 48 unix 3 [ ] SEQPACKET CONNECTED 35988 - ...
# 49 unix 2 [ ] DGRAM 11571 - ...
# 50 unix 3 [ ] SEQPACKET CONNECTED 16759 - ...
# 51 unix 3 [ ] SEQPACKET CONNECTED 13514 - ...
# 52 unix 2 [ ] DGRAM 26323 - ...
# 53 unix 3 [ ] STREAM CONNECTED 19740 - ...
# 54 unix 3 [ ] SEQPACKET CONNECTED 19600 - ...
# 55 unix 3 [ ] STREAM CONNECTED 9918 - ...
# 56 unix 3 [ ] SEQPACKET CONNECTED 16585 - ...
# 57 unix 3 [ ] SEQPACKET CONNECTED 11710 -
-
Notifications
You must be signed in to change notification settings - Fork 0
Splits the elements in a Series using a common separator character and returns a DataFrame.
License
hansalemaos/a_pandas_ex_split_on_common_char
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
 |  | |||
 |  | |||
 |  | |||
 |  | |||
 |  | |||
Repository files navigation
About
Splits the elements in a Series using a common separator character and returns a DataFrame.