0

I'm new to python coding and I'm struggling to add a new column to my pandas framework.

Here's what the column looks like: Time_Difference (it's in seconds) 3 2 5 6

It's a float64 type. And what I wanna create is the following new column : Duration 3 5 10 16

Actually in the format 00:00:00 (The duration adds up to about 2h since I'm tracking a run.)

Now, how to create a new column, that's clear but I struggle with the itterows() or apply() function.

In my naive perception, it should look something like this: df["Duration"] = df["Time_Difference"] + df["Time_Difference"].shift(1) Well, obviously it doesn't.

Couldn't find anything similar on stackoverflow as I don't wanna have the sum of the whole column but on every row.

cz.official
  • 41
  • 1
  • 5

0 Answers0