In [8]:
from datetime import datetime
import pandas as pd

In [4]:
pd.__version__


Out[4]:
'1.0.1'

pandas timestamp now


In [7]:
df = pd.DataFrame({
    "name":["alice","bob","charlie", "david"],
    "age":[12,43,22,34]
})
df


Out[7]:
name age
0 alice 12
1 bob 43
2 charlie 22
3 david 34

In [10]:
df["time"] = pd.Timestamp(datetime.now())
df


Out[10]:
name age time
0 alice 12 2020-02-26 23:24:03.765842
1 bob 43 2020-02-26 23:24:03.765842
2 charlie 22 2020-02-26 23:24:03.765842
3 david 34 2020-02-26 23:24:03.765842

timestamp to string


In [14]:
df = pd.DataFrame({
    "name":["alice","bob","charlie", "david"],
    "age":[12,43,22,34]
})
df["time"] = pd.Timestamp(datetime.now())
df


Out[14]:
name age time
0 alice 12 2020-02-26 23:39:45.399436
1 bob 43 2020-02-26 23:39:45.399436
2 charlie 22 2020-02-26 23:39:45.399436
3 david 34 2020-02-26 23:39:45.399436

In [16]:
df["time_str"] = df["time"].map(lambda ts: ts.strftime("%d-%m-%Y"))

df


Out[16]:
name age time time_str
0 alice 12 2020-02-26 23:39:45.399436 26-02-2020
1 bob 43 2020-02-26 23:39:45.399436 26-02-2020
2 charlie 22 2020-02-26 23:39:45.399436 26-02-2020
3 david 34 2020-02-26 23:39:45.399436 26-02-2020

In [ ]: