Skip to content
Advertisement

Tag: split

Chain df.str.split() in pandas dataframe

Edit: 2022NOV21 How do we chain df.col.str.split() since this returns the split columns if expand = True I am trying to split a column after performing .melt(). If I use assign I end up using the original column and the melted column actually does not even exist. Answer Using expand converts it into a DataFrame, which you do not really

Parse text with uncertain number of fields

I have a file (~50,000 lines) text.txt as below, which contains some gene info from five individuals (AB, BB, CA, DD, GG). The t in the file is a tab seperator. There are also a lot of info that are not useful in the file, and I would like to clean it up. So What I need is to extract

combining split with findall

I’m splitting a string with some separator, but want the separator matches as well: I can’t find an easy way to combine the 2 lists I get: Into the desired output: Answer From the re.split docs: If capturing parentheses are used in pattern, then the text of all groups in the pattern are also returned as part of the resulting

split a string representation with ranges into a list of dates

I have this pandas dataframe column with timeranges (02.07.2021 – 07.07.2021 ) and single days (04.08.2021) as a list. Dates ‘02.07.2021 – 07.07.2021 , 04.08.2021, 19.06.2021 – 21.06.2021’ ‘13.02.2021 – 15.02.2021 , 03.03.2021 ‘ NaN NaN I want this: Dates 02.07.2021, 03.07.2021, 04.07.2021, 05.07.2021, 06.07.2021, 07.07.2021, 04.08.2021, 19.06.2021, 20.06.2021, 21.06.2021 13.02.2021, 14.02.2021, 15.02.2021, 03.03.2021 NaN NaN So basically I want

Advertisement