Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
40 views

Is it possible to color code DataFrame cell values based on its value compared to the value returned from another function. Here is an example of the DataFrame coloring that I created using the ...
Rwt987265's user avatar
0 votes
2 answers
69 views

Objective is to convert each string to uppercase in Pandas dataframe (df). Used following 3 approaches but not sure why 1st is NOT working ? Please refer code snippet and 3 dataframes viz df1, df2, ...
afghani's user avatar
  • 696
1 vote
2 answers
231 views

When I use df.apply(pd.Series.str.upper) shows me an error - Although df.apply(pd.Series.min) is running absolutely fine! and df.apply(lambda x: x.str.upper()) is running fine too. df = pd.DataFrame( ...
Shubham Bhardwaj's user avatar
0 votes
3 answers
1k views

Suppose that we have this dataframe: Value 1 Value 2 Value 3 6 5 6 6 5 10 How to apply color if values on the same column is equals but skip the first column? In my case, column Value 2 must be ...
yunastrian's user avatar
1 vote
1 answer
1k views

DB Policy Snapshot Time A-DB PROD_BACKUP 10/17/2022 12:00:00 B-DB PROD_BACKUP 10/16/2022 10:00:00 C-DB NONPROD_BACKUP 10/15/2022 16:00:00 If the above data is in my dataframe, I pass snapshot time ...
Nick S's user avatar
  • 434
1 vote
1 answer
244 views

I want to locate a specific value which can occur in multiple columns . In my case it's "False" . I know how to search "False" in individual columns as df.loc[df['column1']==False]...
Bhawani Rabisankar Sahoo's user avatar
2 votes
3 answers
1k views

Say I have a dataframe df = pd.DataFrame({'colA' : ['ABC', 'JKL', 'STU', '123'], 'colB' : ['DEF', 'MNO', 'VWX', '456'], 'colC' : ['GHI', 'PQR', 'YZ', '789'],}, ...
Himanshu Poddar's user avatar
0 votes
0 answers
315 views

I am writing a code to compare the datatype of each value in an excel spreadsheet to a database definition spreadsheet which lists the required field/datatypes. I am using dataframe.applymap(type) to ...
RockyFlintstone's user avatar
0 votes
1 answer
145 views

I have two pandas dataframes and want to apply a function "Stat / Percentage Played". The first data frame - "Stat" looks like this: - ----- ------- ------- ------- -------...
RickPeck's user avatar
  • 185
0 votes
1 answer
269 views

I'm trying to highlight specific columns in my dataframe using guideline from this post, https://stackoverflow.com/a/41655055/5158984. My question is on the use of the subset argument. My guess is ...
Huy Truong's user avatar
1 vote
1 answer
810 views

I'd like to find duplicated rows in a Pandas dataframe. When I use df.duplicated() it returns the following error: TypeError: unhashable type: 'list' To resolve this error, I tried the following: ...
mOna's user avatar
  • 2,459
1 vote
1 answer
276 views

I have a pandas dataframe called results that contain 2 columns, one called years containing lists of years and another called line_items containing lists of integers. I am trying to sort the list ...
geds133's user avatar
  • 1,565
0 votes
1 answer
794 views

Given two pandas dataframes df1 and df2 that have exact same schema (i.e. same index and columns, and hence equal size), I want to color just those cells in df1 that are unequal to their counterpart ...
bigO6377's user avatar
  • 1,294
1 vote
1 answer
309 views

General problem : I have two similar data frames (same shape, same variables but different values). How to applymap a function on each cell of df1, according the value of the same cell from df2. My ...
jpetot's user avatar
  • 154
0 votes
2 answers
182 views

I have two dataframes with similar structure like follows: df0 No. Name PropNO PropAmt 1 XYZ - - 2 ABC 1077 34.90 3 GHI - - Total 1077 34.90 df1 No. ...
abhi1610's user avatar
  • 743
0 votes
2 answers
1k views

I have a dataframe as below.. I want to highlight the cells if the value contains delimiter "--" I tried below code. but it throws me error : a b c d 1--2 3 4 None 2 34--32 12 None 23 123--...
Neel333's user avatar
1 vote
2 answers
2k views

How can I perform the following operations on a pandas dataframe? combine text from one column, multiple rows into one row remove duplicates in the "one row" repeat 1 & 2 for multiple ...
a11's user avatar
  • 3,476
-2 votes
1 answer
1k views

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 ...
Gibrail Hassan's user avatar
0 votes
1 answer
89 views

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 ...
Dharmendra Yadav's user avatar
1 vote
1 answer
504 views

enter code hereFirst, I don't know Python but am using it for a team project. I followed a plaid quickstart tutorial. I was able to create a dataframe with the enter code heredata I got back, use it ...
Carole Tierney's user avatar
2 votes
2 answers
2k views

Background Link 1 shows that apply can be applied to a Series. I want to use the apply function on a subset of a DataFrame without looping through the columns. Example code Creating a sample DataFrame ...
Neeraj Hanumante's user avatar
-1 votes
1 answer
354 views

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 ...
alim1990's user avatar
  • 5,012
0 votes
1 answer
929 views

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. ...
Paul C.'s user avatar
  • 177
1 vote
2 answers
2k views

I have a pandas Dataframe with columns of "a" and "b". Column a has a list of values as a column value, and column "b" has a list with a single value that might appear in column "a". I want to create ...
Mojgan Mazouchi's user avatar
0 votes
1 answer
749 views

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(): ...
codingInMyBasement's user avatar
0 votes
1 answer
49 views

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] = ...
Marek Grzenkowicz's user avatar
0 votes
2 answers
53 views

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(...
Noel Harris's user avatar
0 votes
1 answer
1k views

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 ...
XsLiar's user avatar
  • 45
1 vote
1 answer
963 views

I am trying to apply a formula to each value in a Pandas DataFrame, however, I am getting an error. def transform_x(x): return x/0.65 transformed = input_df.applymap(transform_x) This returns the ...
Geodatsci's user avatar
0 votes
2 answers
244 views

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 ...
sync11's user avatar
  • 1,310
1 vote
2 answers
67 views

x1 = [{'id1': 'Africa', 'id2': 'Europe', 'v': 1}, {'id1': 'Europe', 'id2': 'North America', 'v': 5}, {'id1': 'North America', 'id2': 'Asia', 'v': 2,}, {'id1': 'North America', 'id2'...
Chipmunkafy's user avatar
0 votes
1 answer
3k views

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 ...
Neeraja Bandreddi's user avatar
1 vote
1 answer
2k views

I want to use applymap method with a little bit complex function in the dataset below. value1 value2 value3 value4 value5 people 147 119 69 92 106 533.0 31 20 12 ...
mcan's user avatar
  • 2,092
-2 votes
1 answer
188 views

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 ...
Apoorvaa Singh's user avatar
0 votes
0 answers
134 views

I have the following CSV file, that I want to read and reformat with pandas: 10,1.89e-3,1.92e-3,2.14e-3,2.23e-3,2.38e-3,2.43e-3,2.33e-3,2.87e-3 10,1.84,2.01,2.03,1.99,2.11,2.11,2.09,1.95 20,5.28e-4,...
tmaric's user avatar
  • 5,537
2 votes
1 answer
5k views

So i am reading a .xlsx file and i need to check how many variables in the xlsx file belong to each datatype in pandas and finally export it to excel. So here is the code : sheet = pd.read_excel(r"...
explorer_x's user avatar
2 votes
1 answer
85 views

I'd like to highlight (or color) new values in a DataFrame that previously were NaNs. I have 2 data frames with the same index. One with NaNs df_nan = pd.DataFrame(np.random.randint(10, size = (10, ...
solub's user avatar
  • 1,363
1 vote
1 answer
223 views

I got basic DataFrame: df = pd.DataFrame([[1, 2],[3, 4],[5, 6],[7, 8]], index=['A','B','C','D'], columns=['X','Y']) I would like the map function to work on columns X & Y and ...
JCF's user avatar
  • 319
-1 votes
1 answer
679 views

I Have the following table in Pandas. +--------+--------+--------+-----+ | A | B | C | D | +--------+--------+--------+-----+ | foo | b'bar0 | b'foo0 | 253 | | b'bar0 | bar | ...
valenzio's user avatar
  • 823
1 vote
1 answer
2k views

I am trying to use applymap() functionality in pandas to apply a function to a whole dataframe. I have a dataframe df (a sample of it is following): Time 2010-08-31 2010-09-30 2010-10-31 2010-11-...
Pankaj's user avatar
  • 517
2 votes
2 answers
1k views

I am new to pandas. I have written a function which I want to apply to all entries in a pandas DataFrame "Monthly_mean_consump" for which a sample of data is provided below. Time 2010-08-31 2010-...
Pankaj's user avatar
  • 517
1 vote
1 answer
342 views

I read a .csv file into a pandas dataframe delta_df = pd.read_csv('SAAF_121581_67_500_s.dat',index_col=False) - I need to apply the following operation to some of the columns based on the header of ...
coolleaf's user avatar
0 votes
2 answers
595 views

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 ...
sunny's user avatar
  • 683
2 votes
1 answer
4k views

In a pandas Dataframe I want to applymap(somefunction) using groupby (using some column index values). mcve_01.txt pos index M1 M2 F1_x 16230484 141 G/G G/G ...
everestial's user avatar
  • 7,315
2 votes
1 answer
378 views

I have the below data frame ipdb> csv_data country_edited sale_edited date_edited transformation_edited 0 India 403171 20090101 10 1 Bhutan ...
Shiva Krishna Bavandla's user avatar
6 votes
2 answers
4k views

What's the most effective way to solve the following pandas problem? Here's a simplified example with some data in a data frame: import pandas as pd import numpy as np df = pd.DataFrame(np.random....
K. Mao's user avatar
  • 453