split

Split a String with multiple delimiter and get the used delimiter

Split a String with multiple delimiter and get the used delimiter Question: I want to split a String in python using multiple delimiter. In my case I also want the delimiter which was used returned in a list of delimiters. Example: string = ‘1000+20-12+123-165-564’ (Methods which split the string and return lists with numbers and …

Total answers: 2

Split concatenated functions keeping the delimiters

Split concatenated functions keeping the delimiters Question: I am trying to split strings containing python functions, so that the resulting output keeps separate functions as list elements. s=’hello()there()’ should be split into [‘hello()’, ‘there()’] To do so I use a regex lookahead to split on the closing parenthesis, but not at the end of the …

Total answers: 2

How to split a tolist result in two groups (new lists)?

How to split a tolist result in two groups (new lists)? Question: I have a problem, I try many things and I can’t manage to do this. It’s a code that check if the delivery numbers are on our sales report. Here it’s the code: dfn = dfn.astype(‘str’) diff = dfn[~dfn[‘Numero de Envio’].isin(dfn[‘Unnamed: 13’])].dropna()[[‘Numero de …

Total answers: 2

Python: Recursively split strings when longer than max allowed characters, by the last occurrence of a delimiter found before max allowed characters

Python: Recursively split strings when longer than max allowed characters, by the last occurrence of a delimiter found before max allowed characters Question: I have a text transcript of dialogue, consisting of strings of variable length. The string lengths can be anywhere from a few characters to thousands of characters. I want Python to transform …

Total answers: 1

Explode is not working on pandas dataframe

Explode is not working on pandas dataframe Question: I have a dataframe with following columns col1 col2 col3 col4 0 HP:0005709 [‘HP:0001770’] Toe syndactyly SNOMEDCT_US:32113001, C0265660 1 HP:0005709 [‘HP:0001780’] Abnormality of toe C2674738 2 EFO:0009136 [‘HP:0001507’] Growth abnormality C0262361 I would like to explode "col4", i tried different ways to do it but nothing is …

Total answers: 3

Split string from digits/number according to sentence length

Split string from digits/number according to sentence length Question: I have cases that I need to seperate chars/words from digits/numbers which are written consecutively, but I need to do this only when char/word length more than 3. For example, input ferrari03 output must be: ferrari 03 However, it shouldn’t do any action for the followings: …

Total answers: 1

split dataframe text column with given strings – NLP

split dataframe text column with given strings – NLP Question: I have a dataframe with a text column in this form: column_description "this section includes: animals: cats and dogs and vegetables but doesn’t include: plants and fruits: coco" "this section includes the following: axis: x and y but doesn’t include: z, k and c" "this …

Total answers: 2

read a csv file in 3 columns

read a csv file in 3 columns Question: I want to read a csv file with 3 columns: "source","target","genre_ids" with python df = pd.read_csv(‘edges1.csv’,encoding="ISO-8859-1", delimiter=’;;’, header=None,skiprows=1, names=columns,engine="python",index_col=False ) data = pd.concat([df.iloc[:,0].str.split(‘,’, expand=True).rename(columns:=[‘source’,’target’,’genre_ids’]), axis==1]) I want to get: source target genre_ids apple green 21 strawberry red 23 son on edge1.csv contains: source,target,genre_ids apple,green,21 strawberry,red,23 and so …

Total answers: 2

Slice Dataframe in sub-dataframes when specific string in column is found

Slice Dataframe in sub-dataframes when specific string in column is found Question: Assume I have the dataframe df and I want to slice this in multiple dataframes and store each in a list (list_of_dfs). Each sub-dataframe should only contain the rows "Result". One sub-dataframe starts, when in column "Point" the value "P1" and in column …

Total answers: 1