All Questions
227 questions
-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:
...
0
votes
1
answer
172
views
How to create a varlist of strings and change them to numeric variables with decimals?
I have a dataset, and about half of the columns contain string responses of "Yes" "No" and "Maybe". I have the variable names of all of the columns, so a loop response ...
2
votes
3
answers
100
views
Find occurrence of YYYYmmDD date in variable string
Suppose I have a string containing dates in YYYYmmDD format but in variable position and containing also other numeric sequences
For example:
xx12x20240113yyyy123zzzz
20240201xxxx34yyy
...
0
votes
1
answer
88
views
Using encode command to convert string variable to numeric
I have a variable named education, with 0 = primary 1 = secondary 2 = tertiary.
I used encode command to change it from string to numeric, whilst maintaining the labels by:
label define edulabel 0 &...
0
votes
0
answers
19
views
String not converting to numeric [duplicate]
Hi i have strings i want to convert to numeric, basically to get the difference in area under the graph. (I have nothing to add but I have to because StackOverflow says so)
Graph looks something like ...
0
votes
0
answers
48
views
R Programming convert string to numeric [duplicate]
I have a dataset from that website;
https://www.kaggle.com/datasets/aliibrahim10/valorant-stats/code?datasetId=2177984 . And I have a problem.
I have a dataset which includes numeric values but ...
5
votes
10
answers
346
views
Prepend leading zeros to each line of a file
I have a file that looks like this:
1:line1
14:line2
135:line3
15:line4
I need to prepend leading zeros to each line to make it look like this:
00001:line1
00014:line2
00135:line3
00015:line4
Is ...
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 ...
-1
votes
2
answers
76
views
Identify which of two vectors is numeric and which is strings in R (but more generally for other platforms as well)
I need to write a function that identifies which of two vectors it receives is (the most likely to be) the numeric vector and which is (most likely to be) the character vector.
The two vectors might ...
0
votes
1
answer
41
views
How can I perform calculations on numeric data that has some text in cells?
I have some data with suppression in it. Sometimes this is for a 'low' value, sometimes to protect anonymity (with a 'c').
Location
Value
London
1534
Cardiff
238
Wellington
c
Prague
low
At the moment ...
0
votes
1
answer
618
views
How can I validate that a field is either empty or a number?
I want to validate if a received param is either an empty string or a positive number. I tried with:
validates :my_field,
presence: true,
if: ->{
((my_field.is_a? String) && ...
0
votes
0
answers
404
views
Create a matrix with strings and numeric values in memory
I want both string and numeric values in a matrix. I do not want to create a new dataset because in my real code, I have to keep the dataset loaded, so I have to fill this matrix with numeric and ...
0
votes
0
answers
63
views
why a long numeric value changed after converting the variable from character to numeric?
I concatenated some varibales to create an ID, I created two types of variables concatenated (both with same values), one in a string format and the other in a numeric format. But the result differs ...
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 ...
0
votes
1
answer
85
views
Is there a R function (or any way) to color code all numeric values within a single string?
I successfully manage to color code certain words within a string.
However, I am unable to color code ALL numeric values within that same tring.
I want all the numeric values within the string (...