Question: Its probably a *very* basic thing.

but i was wondering how to calculate and sum up the result in a new column.

lets say i have a variable that holds this table below

```
fresh apples     eaten
------------     -----
           2         1
          71        15
          89        32

```

---

i was wondering then, how i could calculate and present **this**:

```
fresh apples     eaten     available
------------     -----     ---------
           2         1             1 
          71        15            56
          89        32            57

```

---

Any tips or help would be **awesome :)**

Answer: 
Using the [`datetime`](https://docs.python.org/3/library/datetime.html#) library with the [`strptime`](https://docs.python.org/3/library/datetime.html#datetime.datetime.strptime) method (for parsing) and the [`strftime`](https://docs.python.org/3/library/datetime.html#datetime.date.strftime) method (for formatting), this can be accomplished with no splits and limited slicing as:

```
from datetime import datetime as dt

date = '2017-08-05T05:21:10.6582942Z'
output = dt.strptime(date[:-2], '%Y-%m-%dT%H:%M:%S.%f').strftime('%Y-%m-%d %H:%M:%S')

```

**Output:**

```
'2017-08-05 05:21:10'

```

**Note:**
The slice is needed to remove the last two characters from the string date, as the `%f` (fractional seconds) formatter only accepts six decimal values, and your string contains seven decimal values.

Per the [formatting documentation](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes):

> 
> `%f`: Microsecond as a decimal number, zero-padded to 6 digits.
> 
> 
>
Start with importing `datetime`:

```
import datetime as dt

```

Convert `string` to `datetime` object:

```
date = "2017-08-05T05:21:10.6582942Z"
new_date = dt.datetime.strptime(date[:-2], "%Y-%m-%dT%H:%M:%S.%f") # -2 slice to since %f only accepts 6 digits.

```

Format `datetime` object as string:

```
format_date = dt.datetime.strftime(new_date, "%Y-%m-%d %H:%M:%S") # returns your format

```

However, looking at your code it feels your `date` is already formatted and you don't require the last `.strftime()` usage.