All Questions
73 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
0
answers
21
views
Series.std() not consistent on identical numbers? [duplicate]
import pandas as pd
print(pd.Series((0.19, 0.19)).std())
print(pd.Series((0.19, 0.19, 0.19)).std())
print(pd.Series((0.19, 0.19, 0.19, 0.19)).std())
Why the first and third row give 0, but the second ...
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 ...
0
votes
1
answer
255
views
python dataframe automatically convert numeric columns as float but don't drop non-numeric
I have created the following function to take a data frame, convert numeric columns d-type to numeric. This is doing good job but the problem is, it drops the non-numeric columns as well, which I don'...
0
votes
1
answer
256
views
Converting alphanumeric values to numeric values in a Python pandas dataframe
Timestamp CAN ID Byte DATA[0] DATA[1] DATA[2] DATA[3] DATA[4] \
1693260 1.478200e+09 0000 8.0 00 00 00 00 00
732574 1.478199e+09 0000 8.0 00 00 ...
0
votes
4
answers
529
views
Pandas dataframe: convert dataframe numeric value to 2 to the power of this numeric value
How do I get the value of 2^(column of pandas dataframe) in another col of a dataframe.
For example:
Value
2^Value
0
1
1
2
1
vote
1
answer
334
views
How to fill NaN only in numeric variables if that variable in on list in Python Pandas?
I have Pandas DataFrame like below:
data types:
COL1 - numeric
COL2 - object
COL3 - numeric
TABLE 1
COL1 | COL2 | COL3
-----|------|------
123 | AAA | 99
NaN | ABC | 1
111 | NaN | NaN
... | ....
0
votes
2
answers
186
views
How to summarize values in DataFrame between defined values in column in Python Pandas?
I have DataFrame in Python Pandas like below:
Data types:
MONTH_NR - numeric
MONTH_NAME - object
VALUE - numeric
MONTH_NR
MONTH_NAME
VALUE
1
JANUARY
10
2
FEBRYARY
20
3
MARCH
15
4
APRIL
10
5
MAY
11
...
0
votes
2
answers
2k
views
Filter DataFrame for numeric values
Let's assume my DataFrame df has a column called col of type string. What is wrong with the following code line?
df['col'].filter(str.isnumeric)
0
votes
2
answers
864
views
How to round only numbers in python dataframe columns with object mixed
I have a dataframe named "df" as the picture.
In this dataframe there are "null" as object(dtype) and numerics.
I wish to round(2) only the numeric values in multiple columns.
I ...
0
votes
4
answers
1k
views
How to filter Pandas Unique Result by only Non-Numeric Values?
Context
I have a Pandas Series and am calling the .unique() Method to get all unique Values. I now would like to filter this result to only see unique Values that are Non-Numeric. However, I get the ...
2
votes
1
answer
196
views
Convert numerical to categorical in python pandas
I have a dataset of internet traffic. There is a ports column I want to convert ports to categorical. This is the code I written to it
df2.loc[df2['Src Port'] == 443] = 'HTTPS'
Now I want to category ...
0
votes
1
answer
164
views
Assert a pandas column type with NaN allowed
I'm coding some tests to verify if some columns of a pandas dataframe are integer (or floats for other columns), but with authorized NaN values.
I'm currently trying with assert statements:
import ...
1
vote
1
answer
89
views
Recode or bin multiple numeric columns as categorical values and summing the counts
I want to recode or bin multiple numeric columns as categorical values and summing the counts. The columns are ages by individual year from 18yrs to 90+ yrs with the cells containing summed totals by ...
0
votes
0
answers
233
views
Error with categorical dataset Seaborn scatterplot
I have converted numerical to categorical data to be used in the legend of a Seaborn scatterplot.
import pandas as pd
import seaborn as sns
data = [['Sample_1', 130, 325, 1989], ['Sample_2', 128, 348,...