Python Forum
Assigning cycle values in a list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Assigning cycle values in a list
#3
Hi, thanks for your reply!

Time sequence are NOT always consecutive in a segment.

Actually, I should have something like this (simplified here)

df = pd.DataFrame({"time": [-3, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, 3, 4, -2, -1, 0, 1, 2, 3], "deltaF_F": [-0.5, 1, 5, 6, 5, -7, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, 3]})
print(df)

Then I should have a script that creates another column called "cycle', in which I assign number of cycles. Given that I have three 0 in the time column, I should have 3 cycles.

In the column "time", the first negative values before the first 0 and all the positive values after this 0 should be attributed Cycle 1. Cycle 2 starts at the next first encountered negative value (-2), reaches the second 0, and ends at last positive value (4). Same for cycle 3.

Best,
Reply


Messages In This Thread
Assigning cycle values in a list - by nmancini - Sep-13-2024, 11:12 PM
RE: Assigning cycle values in a list - by nmancini - Sep-16-2024, 08:44 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  remove duplicates from dicts with list values wardancer84 27 6,569 May-27-2024, 04:54 PM
Last Post: wardancer84
  Writing a cycle to find the nearest point from the array Tysrusko 0 861 May-10-2024, 11:49 AM
Last Post: Tysrusko
  Copying the order of another list with identical values gohanhango 7 2,868 Nov-29-2023, 09:17 PM
Last Post: Pedroski55
  Search Excel File with a list of values huzzug 4 3,039 Nov-03-2023, 05:35 PM
Last Post: huzzug
  Comparing List values to get indexes Edward_ 7 3,711 Jun-09-2023, 04:57 PM
Last Post: deanhystad
  Adding values with reduce() function from the list of tuples kinimod 10 5,816 Jan-24-2023, 08:22 AM
Last Post: perfringo
  user input values into list of lists tauros73 3 2,095 Dec-29-2022, 05:54 PM
Last Post: deanhystad
  Need to fix SyntaxError in cycle try alexfrol86 14 6,401 Mar-27-2022, 07:53 AM
Last Post: stevendaprano
  AttributeError: 'list' object has no attribute 'values' ilknurg 4 21,524 Jan-19-2022, 08:33 AM
Last Post: menator01
  Need to parse a list of boolean columns inside a list and return true values Python84 4 3,396 Jan-09-2022, 02:39 AM
Last Post: Python84

Forum Jump:

User Panel Messages

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