Skip to main content

All Questions

Tagged with
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'...
Mainland's user avatar
  • 4,614
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 ...
Miracle Messiri's user avatar
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
Saraswathy Rajamani's user avatar
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 ...
YJP's user avatar
  • 67
0 votes
2 answers
697 views

Python - Associate Numerical value to Categorical value

I have an excel file with a column like this: Each level is assigned an numerical value where beginner = 1, intermediate = 4, advanced = 10, genius = 20, insane = 50. Is there a way to associate the ...
waterbottle334'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
0 votes
1 answer
765 views

How to replace values in only some columns in Python without it affecting the same values in other columns?

I have a Pandas data frame with different columns. Some columns are just “yes” or “no” answers that I would need to replace with 1 and 0 Some columns are 1s and 2s, where 2 equals no - these 2 need ...
user17199239's user avatar
0 votes
1 answer
499 views

How to convert string entries within a dataset to float?

I am trying to convert string to float in a dataset. The dataset consists of several columns where one of the columns contains entries: col1 col2 x [1.1, 1.2, 1.3 ... When I use pd.to_numeric I get ...
user16470918's user avatar
2 votes
2 answers
6k views

DataError: No numeric types to aggregate

I am going to describe males and females groups by gender to visualize how Churn Rate (1-Retention Rate) looks like for each value. My output df_data.groupby(by='gender')['Churn'].mean() error --------...
Shadic Mersal's user avatar
0 votes
2 answers
88 views

how to regularize numeric/non-numeric entries in pandas dataframes

I want to control for non-numeric entries in my pandas dataframe. Say I have the following: >>> df col_1 col_2 col_3 0 0.01 NaN 0.1 1 NaN 0.9 0.2 2 0.01 NaN 0.3 ...
Jabber1's user avatar
  • 227
13 votes
1 answer
11k views

How to downcast numeric columns in Pandas?

How to optimize the data frame memory footprint and find the most optimal (minimal) data types dtypes for numeric columns. For example: A B C D 0 1 1000000 1.1 1.111111 1 2 -...
Mykola Zotko's user avatar
1 vote
1 answer
488 views

How to merge multiple columns containing numeric data in Pandas, but ignore empty cells

I have a table like this: |-----|-----|-----| | A | B | C | |-----|-----|-----| | | 5 | | |-----|-----|-----| | 1 | | | |-----|-----|-----| | | 5 | | |-----|-----|--...
Raj's user avatar
  • 1,665
0 votes
1 answer
250 views

Change the type of a numeric string with a space separating the decimal places to int/float

I have a pandas column with str values. I need to change its type to int. The problem is that all values are separated with (' ') to differentiate the Ks and the Ms, ex: a = '17 000 000' int(a) print(...
Gabriel Cardoso's user avatar
0 votes
1 answer
43 views

How can I convert a column with values like [1] (objects) to a numeric value?

I want to convert the following column (part of a DataFrame) into a numeric value. df = pd.DataFrame({ "Cluster": [[0], [1], [0], [2]]}) My following code didn't work: pd['Cluster_numeric'] ...
Mars's user avatar
  • 41
2 votes
3 answers
288 views

Is there a python function for finding the numeric and categorical columns?

What is an efficient way of splitting/returning the categorical columns and numeric columns from the pandas data frame in python? So far I'm using the below function for finding the categorical ...
Ailurophile's user avatar
  • 3,005

15 30 50 per page