All Questions
585 questions
1
vote
1
answer
42
views
Is there a fast way to match a column of strings to each substring in a list?
I have a dataframe column which is comprised of strings. I also have a list of substrings. For every substring, I want to test it against each string in the dataframe column, returning True if the ...
-1
votes
1
answer
52
views
How do I use python to zero pad an integer substring (not a whole string) within another string?
Say I have strings like (outputted from running glob.glob() on output from someone else's code):
image-0.png
image-1.png
image-2.png
image-3.png
image-4.png
image-5.png
image-6.png
image-7.png
image-8....
0
votes
2
answers
67
views
Filter a pandas data frame to where one column's values are a substring of another column
I have a pandas dataframe where one column only has the first name of someone who started a task, and another has a column of who completed the task:
StartedTask
CompletedTask
Anne
Anne P
Mary
Kirsten ...
0
votes
4
answers
74
views
How do I extract substrings of a dataframe column by referencing another column?
Let's say I have a dataframe as below:
import pandas as pd
nhl_df = pd.DataFrame({
"team": ["Tampa Bay Lightning", "Boston Bruins", "Toronto Maple Leafs",
...
-1
votes
1
answer
379
views
How to find the longest subsequence containing all vowels in order in a string in Python?
I am working on a problem where I need to find the length of the longest subsequence in a given string that contains all the vowels (a, e, i, o, u) in order and no vowels out of order. The vowels can ...
0
votes
3
answers
353
views
Multiple substrings in string python within variable check [duplicate]
I have the following code:
check = "red" in string_to_explore
How can I replicate it for multiple substrings?
I tried with:
check = "red|blue" in string_to_explore
but doesn't ...
1
vote
3
answers
100
views
How to delete the numbers between two delimiters?
I have some garbage data:
trueText = ' 23 Wolkenvelden en lokaal wat regen. In de ochtend op steeds meer plaatsen ...
0
votes
6
answers
65
views
Extract substring between a : and a string of a predefined set of strings
I have the following input as a a column of a df, each row is one string:
surname: Chardon firstname: Marie occupation: idem link: fille age: 30
surname: Lhopital firstname: Louis-Jean occupation: sp ...
-1
votes
3
answers
96
views
Split string based on delimiter into specific substrings in python stored in multiple columns
I would like to split this string A->B->C->D->E->F into substrings as A->B,B->C,C->D,D->E,E->F.
I tried using split and the delimiter as '->' but that doesn't give the ...
2
votes
3
answers
322
views
Find a substring of 4 consecutive digits and a substring of 3 consecutive digits in a string
I have strings of the type:
1432_ott_457_blusp
312_fooob_bork_1234
broz_901_6453
kkhas_1781_LET_GROK_234
1781_234_kkhas
etc. In other words, each string contains multiple substrings delimited by _. ...
0
votes
0
answers
89
views
I've recently begun experimenting with classes in Python and I'm facing a challenge with string slicing. Here's a snippet of my code
I've recently begun experimenting with classes in Python and I'm facing a challenge with string slicing. Here's a snippet of my code
def future(self):
self.futures = ['you will die soon','you will ...
-2
votes
1
answer
211
views
Format string with substrings
I need to format a string with substrings of a variable. If I do:
sample="1234567890XXXX"
f"{sample[:5]}/{sample[5:10]}/{sample}/config"
It works fine:
'12345/67890/1234567890XXXX/...
0
votes
1
answer
54
views
Chomping left, right string by whitespace to iterate regex matches
The goal is to extract the matching "words" (bounded by \b|$|\s), given the difflib SequenceMatcher.get_matching_blocks() output, e.g. given:
s1 = "HYC00 Schulrucksack Damen, Causal ...
0
votes
1
answer
49
views
Confirm String is a Substring (regardless of order)
I have a code trying to return True if a substring exist within a string
Example 1:
str1 = 'Wolverine vs Freddy Krueger'
str2 = 'Freddy Krueger Vs Wolverine'
str2.find(str1) # returns -1 (False)
...
0
votes
3
answers
102
views
Removing a File Extention from a String in Python (Reverse Indexing)
In a recent project I had to remove the '.txt' extention in a string. I tried using the .find() function as well as .index() and .search() in many ways but nothing came out of it. So, I wrote the ...