extract numerical values from DataFrame string object
NickName:Siraj S. Ask DateTime:2015-06-11T08:17:27

extract numerical values from DataFrame string object

I have a DataFrame object of dtype string. A typical row looks like below:

'\n\n              Dividend Indicated Gross Yield\n          \n\n              1.50%\n          \n'

I am trying to extract only the numerical data from the above string. for example, my desired output should be 1.50.

The other thing to keep in mind is that each row will have different length of numericals and some may include a negative sign too.

I have tried some recommendations involving .rstrip(), regex, convert_objects but they do not work as intended. Any help appreciated.

Copyright Notice:Content Author:「Siraj S.」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/30769519/extract-numerical-values-from-dataframe-string-object

More about “extract numerical values from DataFrame string object” related questions

extract numerical values from DataFrame string object

I have a DataFrame object of dtype string. A typical row looks like below: '\n\n Dividend Indicated Gross Yield\n \n\n 1.50%\n \n' I am trying to extract

Show Detail

Pandas Dataframe: Extract numerical values (including decimals) from string

I have a dataframe consisting of a column of strings. I want to extract the numerical numbers of these strings. However, some of the values are in metres, and some in kilometres. How do i detect that

Show Detail

Extract numerical values from the String type rows from a column

My Requirement is I have a column which consists of below rows. I want to extract only the values(numerical) which starts with $ (Ex- 1620.00 and 4,440.00) and also values which are ended with % (...

Show Detail

How to extract all numerical values from a string column in a big query table and insert them in new numerical columns?

Let's say I have a table like temp_table: CREATE TABLE `YOUR_DATASET.temp_table` ( `F1` STRING, `F2` INT64, `F3` STRING, ); And this table includes some data: INSERT `YOUR_DATASET.temp_table...

Show Detail

How to sort values in DataFrame for both numerical and string values?

I have the following pandas DataFrame with mixed data types: string and integer values. I want to sort values of this DataFrame in descending order using multiple columns: Price and Name. The string

Show Detail

How to sort values in DataFrame for both numerical and string values?

I have the following pandas DataFrame with mixed data types: string and integer values. I want to sort values of this DataFrame in descending order using multiple columns: Price and Name. The string

Show Detail

How to extract all (including int and float) numerical values in a string column in Google BigQuery?

I have a table Table_1 on Google BigQuery which includes a string column str_column. I would like to write a SQL query (compatible with Google BigQuery) to extract all numerical values in str_colum...

Show Detail

Extracting Multiple Numerical Values from String in R

I have a dataset where I would like to extract only the numerical values from the following string: { "What are the last three digits of your zip code?": "043", "What are...

Show Detail

Extracting the numerical values of a xts object

I want to extract the numerical values of a xts object. Let's look at an example data <- new.env() starting.date <- as.Date("2006-01-01") nlookback <- 20 getSymbols("UBS", env = data, src.

Show Detail

Remove all but numerical values from a String in Javascript

I'm learning JS and want to know what's the most efficient way to extract Integer values from Strings like below: const String1 = '122,730 views' const String2 = '2,990 likes' Output: 122730 2990

Show Detail