Skip to main content

All Questions

Tagged with
-1 votes
1 answer
593 views

using pandas to number and coerce to force values to ints and still not working

Confused when I am trying to coerce dataframe to numeric. It appears to work when I look at structure but then I still get errors: TypeError: unsupported operand type(s) for +: 'int' and 'str' Code: ...
user3120266's user avatar
0 votes
1 answer
198 views

SLOW conversion of strings to floats in Python - ways to speed this up?

Summary of Problem I have a data set supplied to me which has geographic coordinates provided as strings with leading spaces and spaces between the positive/negative signs and the numbers. The data ...
brosenheim's user avatar
2 votes
4 answers
50 views

Column of mixed strings and numbers - need to conditionally convert strings to numerical format

I have a script that processes data from a CSV file, however sometimes one of the columns I am using from the CSV file randomly has some of its numbers enclosed in string characters thus making it a ...
verynovice's user avatar
-2 votes
1 answer
75 views

Sort Strings numerical

I analysing Breast Cancer Data Set (archive.ics.uci.edu/ml/datasets/Breast+Cancer) Here is df.head() Class age menopause tumor-size inv-nodes node-caps deg-malig ...
dankie's user avatar
  • 1
2 votes
4 answers
115 views

How can I sort a list of strings in ascending order of numeric part

I have a list of paths which have multiple numerical parts within them, here is part of it: 'C:\\Python\\Python310\\Scripts\\mockup_test\\17mm.JPG', 'C:\\Python\\Python310\\Scripts\\mockup_test\\18mm....
sandvika's user avatar
2 votes
2 answers
2k views

Identify pandas dataframe columns containing both numeric and string

I have created the following dataframe (called df): d = {'ltv': [1, 22,45,78], 'age': [33, 43,54,65],'job': ['Salaried','Salaried','Salaried','Owner'], 'UniqueID' : ['A1','A2','A3','A4'] } df = pd....
Giampaolo Levorato's user avatar
0 votes
1 answer
81 views

How to resolve fractions and subtraction in a pandas string column [duplicate]

I have a dataframe column that includes fractions and subtraction, like so: 60 12.5 6/12 2021-1988 NaN 8/12 3 NaN 2021-2004 5 It's in string format right now. I want it to be numeric. However, when I ...
midnightradi0's user avatar
2 votes
1 answer
3k views

How to find string data-type that includes a number in Pandas DataFrame

I have a DataFrame with two columns. One column contain string values that may or may not include numbers (integer or float). Sample: import pandas as pd import numpy as np data = [('A', '>10'), ...
Mohammad's user avatar
  • 1,023
0 votes
4 answers
890 views

Checking if a string is a number in discord.py

Say for example I have a command that requires 2 arguments, I have an if statement already that checks to see if all arguments are present, however, in this scenario; the first argument should be a ...
TrueVulpis's user avatar
0 votes
2 answers
168 views

inversion of fields with an arabic text and a numeric variables

I need to print the below string of two fields which is first an Arabic and he second a numéric values. >>> s1 = 'مرحبا بالجميع' >>> s2 = '1' >>> print('{} - {}'.format(s1,...
YaOo's user avatar
  • 1
0 votes
1 answer
51 views

Getting numeric data from extracted texts using python

I have extracted the tweets and locations of the users as well as other essential tweet information. The next step is extracting the water level data (that is, if the tweet has a 'number' followed by '...
kiwi_kimchi's user avatar
0 votes
2 answers
572 views

Can't convert 'str' to numerical value in Python 3.0

I am a new python coder so bare with me. I want to convert certain columns from 'str' to 'int' or 'float'. However, no matter what code I apply to the columns (pd.to_numerical, astype(int) etc), it ...
xnarogia's user avatar
0 votes
2 answers
282 views

Extract continuous numeric characters from a string in Python

I am interested in extracting a number that appears after a set of characters ('AA='). However, the issue is: (i) I am not aware how long the number is, (ii) I don't know what appears right after the ...
nuki's user avatar
  • 101
-2 votes
2 answers
7k views

TypeError: sequence item 0: expected str instance, int found i keep getting a type error in the last line [closed]

i keep getting a typeerror on this code specifically in the last line .join(Q). can anyone help me with it? Q=[] a = Question.split() for i in a: if i in stop: continue else: ...
Eyad Ahmed's user avatar
1 vote
1 answer
847 views

Python: how to split string by groups Alpha-numeric vs numeric

Lets say I have Strings like: "H39_M1", "H3_M15", "H3M19", "H3M11", "D363_H3", "D_128_H17_M50" How can I split them every single one into a ...
HR_quantile's user avatar

15 30 50 per page