Question: I'm using python with pandas and datetime.

I have dataframe in csv file like that:

[![enter image description here](https://i.stack.imgur.com/f3vFF.png)](https://i.stack.imgur.com/f3vFF.png)

I too add new column called "Duration" by subtracting "Start date" from "End date".

what I have tried to do:

```
rides['Duration'] = end_time - start_time
duration = rides['Duration']

print(rides['Duration'])

```

and what I get is:

```
0     0 days 00:03:01
1     0 days 02:07:02
2     0 days 00:05:43

```

what I want to get is:

```
0     00:03:01
1     02:07:02
2     00:05:43

```

That is, I want to remove the "days" and show only the time.

Answer: 
You can pass variable number of arguments to `itertools.product` with `*`. `*` is the unpacking operator that unpacks the list and passes its values the values of list to the function as if they are separately passed.

```
import itertools
import math

A = [[1, 2], [3, 4], [5, 6]]

result = list(map(math.prod, itertools.product(*A)))
print(result)

```

Result:

```
[15, 18, 20, 24, 30, 36, 40, 48]

```

---

You can find many explanations on the internet about `*` operator. In short, if you call a function like `f(*lst)`, it will be roughly equivalent to `f(lst[0], lst[1], ..., lst[len(lst) - 1])`. So, it will save you from the need to know the length of the list.

Edit: I just realized that `math.prod` is a 3.8+ feature. If you're running an older version of Python, you can replace it with its numpy equivalent, `np.prod`.
You could use a [reduce function](https://realpython.com/python-reduce-function/) that is intended exactly for these types of operations, which is based on recursion and accumulation. I am providing you an example with a primitive function so you can better understand its functionality:

```
lists = [
    [4, 6, 8],
    [1, 3, 5]
]

def reduce(function, iterable, initializer=None):
    it = iter(iterable)
    if initializer is None:
        value = next(it)
    else:
        value = initializer
    for element in it:
        value = function(value, element)
    return value

def cmp(a, b):
    for x in a:
        for y in b:
            yield x*y

summed = list(reduce(cmp, lists))

# OUTPUT

[4, 12, 20, 6, 18, 30, 8, 24, 40]

```

In case you need it sorted just make use of the [sort() function](https://www.geeksforgeeks.org/python-list-sort/).