Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandascheck if two columns match and populate new column

import numpy as np
import pandas as pd

a = [['10', '1.2', '4.2'], ['15', '70', '0.03'], ['8', '5', '0']]
df = pd.DataFrame(a, columns=['one', 'two', 'three'])

df['que'] = np.where((df['one'] >= df['two']) & (df['one'] <= df['three'])
                     , df['one'], np.nan)
Comment

PREVIOUS NEXT
Code Example
Python :: asyncio run in executor 
Python :: was en francais 
Python :: Jupyter get cell output 
Python :: reverse every word from a sentence but maintain position 
Python :: how to identify set list and tuple in python 
Python :: python regex get start end indices for searching word 
Python :: numpy array filter and count 
Python :: databases not showing in odoo 13 
Python :: python source script custom functions 
Python :: Filter dataarray 
Python :: pandas impute with mean of grupby 
Python :: make n copies of item in list 
Python :: print all data in excel openpyxl 
Python :: add legend to px.choropleth map python 
Python :: install first person controller python 
Python :: python inverse dict with repeating values 
Python :: Assigning X and y using .iloc index 
Python :: int and text on same line python 
Python :: dict to csv keys as rows and subkey as columns in python 
Python :: somebody please get rid of my annoying-as-hell sunburn!!! 
Python :: rotch randn 
Python :: How to put a header title per dataframe after concatenate using pandas in python 
Python :: lamda in f string 
Python :: pandas resample fill missing values 
Python :: discord.py get channel object from id 
Python :: Parallel run of a function with multiple arguments partial map pool 
Python :: Read large SAS file ilarger than memory n Python 
Python :: powershell open file with default program 
Python :: foreach loop in python with index 
Python :: pandas add missing rows from another dataframe 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =