Questions tagged [python-applymap]
44 questions
0
votes
1 answer
Why apply function did not work on pandas dataframe
ct_data['IM NO'] = ct_data['IM NO'].apply(lambda x: pyffx.Integer(b'dkrya@Jppl1994', length=20).encrypt(int(x)))
I am trying to encyrpt here is below head of ct_data
Unnamed: 0 IM NO CT ID
0 …

Dharmendra Yadav
- 49
- 8
0
votes
1 answer
Python - Pandas - Style.ApplyMap working strange
Can anybody help me out with the following strange scenario?
So I have the following Table ( Oracle ) which looks like as follows:
Screenshot
Going back to python, I have created the following Script. I connect to the database and afterwards I…

Paul C.
- 167
- 1
- 8
0
votes
1 answer
Apply Function for Text Cleaning to Multiple Columns
I have three columns of text in my dataframe that I want to apply the same function to. Here is what I have tried below. What should I pass as a parameter to my function?
def clean_columns():
df['column'] =…

codingInMyBasement
- 728
- 1
- 6
- 20
0
votes
1 answer
Modifying an indexed DataFrame inside a function changes the original variable
The following script prints the same input variable input_df twice at the end - before and after df_lower has been called:
import pandas as pd
def df_lower(df):
cols = ['col_1']
df[cols] = df[cols].applymap(lambda x: x.lower())
return…

Marek Grzenkowicz
- 17,024
- 9
- 81
- 111
0
votes
2 answers
Why doesn't the clean-up persist?
I clean a csv table. I want to delete symbols in the ID. It looks like this:
ID Address
"(2 Hamburg
"(3 Cologne
"(4 Berlin
"(5 ...
I want to delete the "(
The code I used
Ost.applymap(lambda x: x.replace('"(', ''))
when I check the csv…

Noel Harris
- 131
- 1
- 13
0
votes
1 answer
Count and map number of appearances of strings
I am mapping specific keywords with text data using applymap in Python. Let's say I want to check how often the keyword "hello" matches with the text data over all rows. Applymap gives me the desired matrix outcome, however only a "True" or "False"…

XsLiar
- 35
- 7
0
votes
2 answers
Get the maximum length of a word from a paragraph
I am working on a text problem where I have my pandas dataframe holding many columns out of which one consists of paragraphs. What I need in output are 3 columns as defined -
Length of largest words
Number of largest words (in case if there are…

sync11
- 1,224
- 2
- 10
- 23
0
votes
1 answer
call multiple argument function in applymap in python
I wrote a function for giving colors to the variables for pandas data frame.
there I used two arguments first one is variables list and another is threshold values list(i'am having only two values in the list e.g, say 30 and 50) for color the…

Neeraja Bandreddi
- 437
- 2
- 18
0
votes
0 answers
Using a formatter function with pandas.DataFrame.applymap has no effect
I have the following CSV file, that I want to read and reformat with pandas:…

tmaric
- 5,347
- 4
- 42
- 75
0
votes
2 answers
How to use applymap in python pandas dataframe to handle scale for normalization
Firstly, i apologize for a vague question . Let me explain.
I have a pandas dataframe containing 2 columns namely square feet and number of bedrooms. I am trying to compute the price using linear regression and want to run the matrix to compute…

sunny
- 643
- 2
- 11
- 29
-1
votes
1 answer
Python replace NaN values of a field holding numeric values with empty and not single quotes which will be treated later as strings
I am uploading some data frames into snowflake cloud. I had to use the following to transform all field values into string:
data = data.applymap(str)
The only reason I am doing that is that without it, I will get the following error:
TypeError:…

alim1990
- 4,656
- 12
- 67
- 130
-1
votes
1 answer
Python: Apply function to certain elements/cells in pandas dataframe
I Have the following table in Pandas.
+--------+--------+--------+-----+
| A | B | C | D |
+--------+--------+--------+-----+
| foo | b'bar0 | b'foo0 | 253 |
| b'bar0 | bar | blah | 485…

valenzio
- 773
- 2
- 9
- 21
-2
votes
1 answer
Remove NaN from lists in Pandas dataframe
I have a dataframe whose values are lists which contains 'nan'. Is there an easy and pythonic way to remove those 'nan' values from lists within the dataframe? I have defined a function which returns a list without 'nan', but how can I apply it to…

Gibrail Hassan
- 85
- 7
-2
votes
1 answer
Apply function in python (dataframe)
I read that the apply function takes the entire series as the input and apply the custom function to that series. However I applied the below function to a col in a dataframe and it worked as if It was passing data element wise (because it was…

Apoorvaa Singh
- 29
- 1
- 6