Python Forum
Drop rows from data with zero value
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Drop rows from data with zero value
#2
Line 12 below will do it for you.

data = [
    ["2018-01-01", 0],
    ["2018-01-02", 1],
    ["2018-01-03", 0],
    ["2018-01-04", 0],
    ["2018-01-05", 0],
    ["2018-01-06", 31],
    ["2018-01-07", 0],
    ["2018-01-08", 0]
]

data2 = [entry for entry in data if entry[1] != 0]
print(data2)
Reply


Messages In This Thread
Drop rows from data with zero value - by Devilish - Dec-26-2018, 11:50 PM
RE: Drop rows from data with zero value - by stullis - Dec-26-2018, 11:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Dropping Rows From A Data Frame Based On A Variable JoeDainton123 1 2,238 Aug-03-2020, 02:05 AM
Last Post: scidam
  How to shift data frame rows of specified column Mekala 0 1,914 Jul-21-2020, 02:42 PM
Last Post: Mekala
  Filter rows by multiple text conditions in another data frame i.e contains strings an Pan 0 2,166 Jun-09-2020, 06:05 AM
Last Post: Pan
  How can I convert time-series data in rows into column srvmig 0 2,084 Apr-11-2020, 05:40 AM
Last Post: srvmig
  Panel Data Cleaning Drop Identity luxlambo 1 1,618 Jan-13-2020, 09:55 PM
Last Post: jefsummers
  drop rows that doesnt matched karlito 6 3,080 Oct-28-2019, 12:21 PM
Last Post: karlito
  Drop rows if a set of columns has a value dervast 1 1,996 Sep-12-2019, 04:18 PM
Last Post: sd_0912
  Creating new rows and adding them to empty data frame kapilan15 0 1,671 May-31-2019, 10:19 AM
Last Post: kapilan15
  How to filter specific rows from large data file Ariane 7 8,236 Jun-29-2018, 02:43 PM
Last Post: gontajones
  how to select particular rows data from a array raady07 3 4,434 Mar-06-2017, 02:21 AM
Last Post: raady07

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020