Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
0 votes
1 answer
21 views

Remove common company name suffixes in Python using regex

I'm struggling to remove suffixes from some company names. The expected result is like below: Original Names: Apple Inc. Sony Corporation Fiat Chrysler Automobiles S.p.A. Samsung Electronics Co., Ltd. ...
Mahdi's user avatar
  • 1,007
0 votes
3 answers
50 views

Python, pandas parse number and string from string

In Python, I want to parse a string and return the numeric portion (may or may not have decimal point) as a float and return the suffix as a string. Examples are: 7.1inch -> 7.1, inch 7.1” -> ...
tosa's user avatar
  • 411
1 vote
2 answers
51 views

How to find all occurrences of a substring in a string while ignoring some characters in Python?

I'd like to find all occurrences of a substring while ignoring some characters. How can I do it in Python? Example: long_string = 'this is a t`es"t. Does the test work?' small_string = "test&...
Franck Dernoncourt's user avatar
0 votes
0 answers
24 views

How to modify a "Name+2nd name+Surname without touch 2nd name? Phyton

I want to change 2 characters in a variable in phyton but when I fix one the other change again. I have this variable. name= " rIana Danyela RodrYguez " I don't want to touch the name &...
TIFK's user avatar
  • 1
1 vote
1 answer
57 views

Comparing string uniforming special characters in python [duplicate]

Probabily I can use a better english but what I want is ignoring accent (and like) in words so: renè, rené, rene' and rene should be the same so should mañana and manana or even-distribuited and even ...
fabio's user avatar
  • 1,299
-8 votes
0 answers
46 views

Python. How to parse indented text to dicts?

I have this text from the log. How to convert it to a dictionary? The ultimate goal is that ITEMs that contain a date do not need to be converted (item[3,4]). CodAnsw = 12 IdentAnsw = 1 Data: ...
Andy_bat's user avatar
0 votes
1 answer
33 views

Managing wrong order of strings in R and ggplot. X1, X10, X12: How can I ensure a string with number will be preented in the right numberical order?

Every time that I want to plot or list a string that contains numbers, R (and python) list the values such as "x1, x10, x11, x13, (etc) x2, x3, x4" I tried to solve this using gtools::...
Luis's user avatar
  • 1,554
-2 votes
0 answers
41 views

TypeError: 'str' object is not callable - Convert str to int [closed]

i'm trying to convert string to float, but appears this type error: TypeError Traceback (most recent call last) <ipython-input-133-93612055e8fb> in <cell line: ...
Gabriela Lira Bertolo's user avatar
-2 votes
1 answer
97 views

Python string: extract duplicated and randomly merged substring

Example of duplicated and merged string: 16.01068.0%0 8p%.a .p .a. Desired substring to be extracted: 16.008% p.a. Fuller example: CCoonnttiinnggeenntt CCoouuppoonn 16.01068.0%0 8p%.a .p (.Ma.o (...
Big Data Newbie's user avatar
-2 votes
1 answer
63 views

I can't reproduce input embedded in a contest interface

I solved a contest task but couldn't submit it because I can't reproduce input embedded in the contest interface. Input is defined in 4 strings, each can be empty but has at its end a symbol for line ...
TiimeIrre's user avatar
  • 169
-1 votes
0 answers
48 views

cleaning list object containing text and creating new variables using Python

I am trying to create a data frame running the following code - # pip install edgartools import pandas as pd from edgar import * # Tell the SEC who you are set_identity("Your Name youremail@...
Sharif's user avatar
  • 177
0 votes
4 answers
59 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", ...
JJin's user avatar
  • 1
-1 votes
2 answers
58 views

Why do I not get the more helpful "sum() can't sum strings, use join" message, but "unsupported operand types for +"?

I'm learning Python now. I created a function def my_func(my_tuple): return sum(my_tuple) Then I do print(my_func(("a", "b"))) And I get: TypeError: unsupported operand type(...
User985468376's user avatar
0 votes
1 answer
50 views

Unicode strings in a purely python3 codebase - are these useless? [duplicate]

In the codebase that I'm working on, there seems to be remnants of python2 because a lot of the strings are prefixed with u. From researching, it looks like this denotes a unicode string, but in ...
NFeruch - FreePalestine's user avatar
0 votes
2 answers
60 views

Strings .sort(key=?) function

I run a following code from the Python textbook: strings = ['foo','card','bar','aaaa','abab'] strings.sort(key= lambda x : len(set(list(x)))) print(strings) Out: ['aaaa', 'foo', 'abab', 'bar', '...
jumi's user avatar
  • 27

15 30 50 per page
1
2 3 4 5
2167