Python Forum
How to check multiple columns value within range
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to check multiple columns value within range
#1
Hi all,

The demo is wanted check multiple columns within range(filter out of range row) and pick up other columns.

when chosen one column that can work by between function, but add more columns got an error.

import pandas as pd df=pd.read_csv(r'log.csv',header=1).drop([0,1]) df1=df['VDD Continuity'].between(-0.8,-0.25,inclusive ='both') print(df[df1]['DUT_NM_Noise']) # It is work as well. df1=df[['VDD Continuity','LR Continuity','DATA Continuity','SCLK Continuity']].astype('float').between(-0.8,-0.25,inclusive ='both') print(df[df1]['DUT_NM_Noise']) It doesn't work.
Is there have a good way to handle the issue,thanks!!
Reply
#2
Try this.
import pandas as pd df = pd.read_csv(r'log.csv', header=1).drop([0, 1]) # Filter rows based on multiple columns filter_cond = ( df['VDD Continuity'].between(-0.8, -0.25, inclusive='both') & df['LR Continuity'].between(-0.8, -0.25, inclusive='both') & df['DATA Continuity'].between(-0.8, -0.25, inclusive='both') & df['SCLK Continuity'].between(-0.8, -0.25, inclusive='both') ) filtered_df = df.loc[filter_cond] result = filtered_df['DUT_NM_Noise'] print(result)
Reply
#3
It's work, thanks for you.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Exploding multiple columns Mormolyce 2 2,646 Sep-07-2025, 02:13 PM
Last Post: Mormolyce
  Check DataFrames with different sorting in columns and rows Foxyskippy 0 1,533 Nov-19-2022, 07:49 AM
Last Post: Foxyskippy
  How to move multiple columns to initial position SriRajesh 4 3,821 Jul-02-2022, 10:34 AM
Last Post: deanhystad
  df column aggregate and group by multiple columns SriRajesh 0 2,120 May-06-2022, 02:26 PM
Last Post: SriRajesh
  Split single column to multiple columns SriRajesh 1 2,421 Jan-07-2022, 06:43 PM
Last Post: jefsummers
  matplotlib x axis range goes over the set range Pedroski55 5 8,468 Nov-21-2021, 08:40 AM
Last Post: paul18fr
  Apply fillna to multiple columns in dataframe rraillon 2 5,130 Aug-05-2021, 01:11 PM
Last Post: rraillon
  Pandas: how to split one row of data to multiple rows and columns in Python GerardMoussendo 4 11,714 Feb-22-2021, 06:51 PM
Last Post: eddywinch82
  How to fill parameter with data from multiple columns CSV file greenpine 1 3,288 Dec-21-2020, 06:50 PM
Last Post: Larz60+
  convert string into multiple columns in python3 VAN 2 3,981 Sep-26-2020, 11:14 PM
Last Post: scidam

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.