Skip to main content

All Questions

Tagged with
0 votes
1 answer
31 views

String cleaning removing consecutive value and put comma in the end

I have this string from an email I'm scraping: TICKET\xa0\xa0 STATE\xa0\xa0\xa0\xa0 ACCOUNT IDENTIFIER\xa0\xa0\xa0 FILE DIRECTORY\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\...
Maku's user avatar
  • 1,610
0 votes
4 answers
180 views

Replace a series of the same character by its number of occurrences in the series [duplicate]

I get a string like this: AABBBB$CCCDEEE$AABADEE And I want a result like this: 2A4B$3CD3E$2ABAD2E To do that, I made a for loop on the string array. It works well: import re string = "AABBBB$...
Tawal's user avatar
  • 89
0 votes
1 answer
110 views

Substitute substring with multiple characters

I am trying to make a string replacement using regex, but I am not able to achieve the expected result. I have a list of strings ['INSUTRIN 150G','NEUROZINE 30 ML','INSULITROL 30 CAPS'] for example. I ...
Leonardo Lima Ferreira's user avatar
2 votes
3 answers
93 views

Replace subtrings in a list of strings using dictionary in python

I have a list of substrings: ls = ['BLAH a b c A B C D 12 34 56', 'BLAH d A B 12 45 78', 'BLAH a/b A B C 12 45 78', 'BLAH a/ b A 12 45 78', 'BLAH a b c A B C D 12 34 99'] I want to ...
frank's user avatar
  • 3,656
0 votes
2 answers
87 views

How to convert a string in python to separate strings [closed]

I have a pandas dataframe with only one column containing symbols. I need to separate those symbols in groups of 13 and 39 inside a single string. symbol 3IINFOTECH 3MINDIA 3PLAND 20MICRONS 3RDROCK ...
Hamza Ahmed's user avatar
  • 1,811
1 vote
1 answer
64 views

Parsing string to dictionary

I'm working on a communications project with a radio that transmits a formatted string message, similar to: message_string = 'Transmission\n variables \n 0.01 First variable\n 0.02 Second variable\n ...
AmericanJael's user avatar
0 votes
0 answers
34 views

Python Dataframe Find Strings and Change Their Values

I have a dataframe includes 15 columns. Data mining process is ongoing. degree_type column has lower and uppercase letters, punctuation and abbreviation. I want to find all Bachelor's Degrees (in the ...
Rebeka's user avatar
  • 81
-1 votes
2 answers
204 views

Formatting JSON for Python - need to remove \"

I've got some JSON that looks like this: {"name": "John", "description": "I'm just \"A BOY\" okay? He said \"Hello, World!\" to everyone.", ...
alexander s's user avatar
1 vote
4 answers
96 views

How to replace double quotes within double quotes in a string with a specific string?

name = "HIGHLY"SUCCE?SS+"FUL"RATE" i need a Python code where I need to replace double quotes with {+} except the ones in the ends, that is replace 2nd and 3rd and 4th double ...
sreelu r's user avatar
1 vote
1 answer
70 views

Replacing multiple overlapping substrings in a string

I have a string in an HTML document. astring = "R=500 mm, φ=180°, Z=599 mm von TL Boden oben. Unterliegende Schale: Boden oben." I want to replace substrings of astring to make links. For ...
jake77's user avatar
  • 2,054
1 vote
2 answers
131 views

conditional replace of a string in python

I want to perform conditional replace of string. if my string = "abaabaaabaaaabaaabaaaaaabaababaaabaaaabaaaaaabaaaaabaaabaabaababaaabaaaabaaaabaabaaab" and I want to replace a with 2 ...
Rashid Ansari's user avatar
2 votes
3 answers
63 views

python replace in string

a = "kava" a = a.replace(a[3:], "-" * (len(a) - 3)) print(a) In words without multiple characters is it OK. For example "kavo". But in "aaaa" replace all ...
Rastislav's user avatar
-2 votes
3 answers
101 views

A more Pythonic Way to clean up strings

I am looking to clean up some strings to make them column names and the easiest method i found is a series of replace statements: is there a cleaner way to achieve this outcome? Sample String for ...
Tinkinc's user avatar
  • 454
0 votes
0 answers
46 views

Pythonic way to replace a character from a specific position in a string [duplicate]

Consider the word "Data Analytycs" for example. I would like to write a code which specifies "Replace second y of the string". Could someone please explain the most pythonic way to ...
Sri Ram's user avatar
  • 33
2 votes
1 answer
159 views

Regex string parsing: pattern starts with ; but can end with [;,)%&@]

I am attempting to parse strings using Regex. The strings look like: Stack;O&verflow;i%s;the;best! I want to parse it to: Stack&verflow%sbest! So when we see a ; remove everything up until ...
Pleasant Gopher's user avatar

15 30 50 per page
1
2 3 4 5
86