Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Drop rows if a set of columns has a value
#2
Instead of dropping the rows, you need to filter the dataframe instead, something like this:

import pandas as pd
small_df=pd.DataFrame(columns=['1','2','3','4','5','dist','unique'])
small_df = small_df.append([{
  "1": 100,
    "2": "Test",
    "3": "Test"
},
{
    "1": "Test",
    "2": 100,
    "3": "Test"
},
{
    "1": "Test",
    "2": "Test",
    "3": "Test"
}], ignore_index=True)

small_df

small_df = small_df[(small_df['1'] == 100) | (small_df['2'] == 100) | (small_df['3'] == 100) | (small_df['4'] == 100)]
small_df
Quote

Top Page

Messages In This Thread
RE: Drop rows if a set of columns has a value - by sd_0912 - Sep-12-2019, 04:18 PM

Possibly Related Threads...
Thread Author Replies Views Last Post
  read_csv error and rows/columns missing karlito 9 592 Nov-11-2019, 06:48 AM
Last Post: karlito
  drop rows that doesnt matched karlito 6 559 Oct-28-2019, 12:21 PM
Last Post: karlito
  display graph in columns and rows william888 1 457 Jul-02-2019, 10:19 AM
Last Post: dataman
  Drop rows from data with zero value Devilish 3 931 Dec-27-2018, 02:06 AM
Last Post: Devilish
  Dropping all rows of multiple columns after the max of one cell Thunberd 2 948 Jun-01-2018, 10:18 PM
Last Post: Thunberd
  Get rows with same value from dataframe of particular columns angelwings 1 946 Apr-11-2018, 02:40 AM
Last Post: scidam
  summing rows/columns more quickly jon0852 3 1,013 Feb-12-2018, 02:24 AM
Last Post: ka06059
  Stack dataframe columns into rows klllmmm 0 1,393 Sep-03-2017, 02:26 AM
Last Post: klllmmm

Forum Jump:


Users browsing this thread: 1 Guest(s)