Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 9 months ago. Improve this question
Tag: string
Remove character from a string and list all possible permutations
I’m trying to go through a string and every time I come across an asterisk (*) replace it with every letter in the alphabet. Once that is done and another asterisk is hit, do the same again in both positions and so on. if possible saving these permutations to a .txt file or just printing them out. This is what
Convert string duration column to seconds
In the dataframe, one of the columns is duration. It was given as a string. How can I convert this column into seconds? Answer Use pd.Timedelta to parse each item: Output:
Print text from right side
May I know how to print text to the right side like: I only know center code is this: Thanks Edit str.rjust(165//2) is center text from: How to place input function in center of page? Answer You are doing well just try to use an int like this The first value is the amount of space de second is the
How can I remove in Python “-” from spaces and keep them between words?
I have a string with different words in Python. The string is connected with a “-” between the words and the spaces, as shown in the example below. I tried using the replace and split method to remove the “-” in the spaces. However, I can only get it to remove them all, but I need the hyphens between the
New rows based on a string – Pandas. python
I have this pandas df I need to be able to break down the ‘cast” field in such a way that it is in several rows Example: I understand that I should do it with pandas, but it is very complicated, can you help me? Answer You can use spit and explode:
Why there is space and p in last line in output?
this is the output Why there is space and p in last line in output ???? Answer It is because your string contains a space and n is treated as a line break, leaving a p at the end of each line.
Represent string characters as hex values in python
I’m trying to represent a given string in hex values, and am failing. I’ve tried this: For the first one I get “ValueError: non-hexadecimal number found in fromhex() arg at position 0” error For the second I get that there’s no decode attribute to str. It’s true but I found it here so I guessed it’s worth a shot. My
Search and replace specific strings with floating point representations in python
Problem: I’m trying to replace mutiple specific sequences in a string with another mutiple specific sequences of floating point representations in Python. I have an array of strings in a JSON-file, which I load to a python script via the json-module. The array of strings: I load the JSON-file via the json-module: I’m trying to replace the sequences of _
Pandas dataframe reports no matching string when the string is present
Fairly new to python. This seems to be a really simple question but I can’t find any information about it. I have a list of strings, and for each string I want to check whether it is present in a dataframe (actually in a particular column of the dataframe. Not whether a substring is present, but the whole exact string.