Python Forum
Creating column in python based on the other colums value count
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating column in python based on the other colums value count
#1
Photo 
Hello everyone!

Can someone help me, what code should I use to create a new column which will display cumulatively the number of preceding rows in which "0" appeared in the column NumEvents. The counting should reset and begin from 0 again every time a new record in the column USERS_PK1 appears.
from:

[Image: upRoh.png]

to smth like this:
[Image: ysqSC.png]

Thanks in advance!
Reply


Messages In This Thread
Creating column in python based on the other colums value count - by Bartek635 - Apr-13-2021, 07:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Question on pandas.dataframe merging two colums shomikc 4 874 Jun-29-2023, 11:30 AM
Last Post: snippsat
  create new column based on condition arvin 12 2,350 Dec-13-2022, 04:53 PM
Last Post: jefsummers
  Row Count and coloumn count Yegor123 4 1,379 Oct-18-2022, 03:52 AM
Last Post: Yegor123
  How to assign a value to pandas dataframe column rows based on a condition klllmmm 0 873 Sep-08-2022, 06:32 AM
Last Post: klllmmm
  Reshaping a single column in to multiple column using Python sahar 7 2,115 Jun-20-2022, 12:35 PM
Last Post: deanhystad
  df column mean and count of unique SriRajesh 0 1,133 May-07-2022, 08:19 AM
Last Post: SriRajesh
  Creating a numpy array from specific values of a spreadsheet column JulianZ 0 1,160 Apr-19-2022, 07:36 AM
Last Post: JulianZ
  Openpyxl-change value of cells in column based on value that currently occupies cells phillipaj1391 5 9,942 Mar-30-2022, 11:05 PM
Last Post: Pedroski55
  NaN when creating a new column... Menthix 2 1,221 Mar-15-2022, 08:40 AM
Last Post: Menthix
  pandas pivot table: How to find count for each group in Index and Column JaneTan 0 3,362 Oct-23-2021, 04:35 AM
Last Post: JaneTan

Forum Jump:

User Panel Messages

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