<jupyter_start><jupyter_text>Date and Time<jupyter_code>!uname -a<jupyter_output>Linux 7ffcd48b9889 4.15.0-1065-aws #69-Ubuntu SMP Thu Mar 26 02:17:29 UTC 2020 x86_64 GNU/Linux<jupyter_text>seconds since the epoch (1970-01-01 UTC)<jupyter_code>!date +'%s'<jupyter_output>1598963249<jupyter_text>Convert seconds since the epoch (1970-01-01 UTC) to a date<jupyter_code>!date --date='@1593942818'<jupyter_output>Sun Jul  5 09:53:38 UTC 2020<jupyter_text>`dt.datetime`<jupyter_code>import datetime as dt

now = dt.datetime.now()
now-dt.timedelta(minutes=10)
now.replace(year = now.year + 1)
now.replace(month =  now.month + 1)
dt.datetime.now().strftime('%Y.%m.%d %H:%M:%S')<jupyter_output><empty_output><jupyter_text>seconds since the epoch (1970-01-01 UTC)<jupyter_code># date +'%s'
dt.datetime.now().strftime("%s")
dt.datetime.fromtimestamp(1593943632)<jupyter_output><empty_output><jupyter_text>parsing string* strptime = "string parse time"* strftime = "string format time"<jupyter_code>import datetime as dt
dt.datetime.strptime('Jun 1 2005  1:33PM', '%b %d %Y %I:%M%p')
print(dt.datetime(2005, 6, 1, 13, 33))<jupyter_output>2005-06-01 13:33:00<jupyter_text>YYYY-MM-DD `dt.datetime.fromisoformat`In Python >= 3.7.0,`dt.datetime.fromisoformat` to convert YYYY-MM-DD string to datetime object, could be used.<jupyter_code>dt.datetime.fromisoformat('2005-06-01 13:33:00')<jupyter_output><empty_output><jupyter_text>`pandas.Timestamp()`<jupyter_code>import pandas as pd
pd.Timestamp(dt.datetime.now())
pd.Timestamp(dt.datetime.now()).value<jupyter_output><empty_output><jupyter_text>from `pd.Timestamp` to `dt.datetime.fromtimestamp`<jupyter_code>pd.to_datetime(1593943613376313000)
== // 1e9 nano
pd.Timestamp(dt.datetime.now()).value//1e9
dt.datetime.fromtimestamp(1593943780.0)
now = dt.datetime.now()
now-dt.timedelta(minutes=10)
pd.Timestamp(now-dt.timedelta(minutes=10)).value
now.strftime("%s")<jupyter_output><empty_output><jupyter_text>`numpy.linspace`<jupyter_code>import numpy as np
import datetime as dt
import pandas as pd

now = dt.datetime.now()
t = np.linspace(pd.Timestamp(now-dt.timedelta(minutes=10)).value, pd.Timestamp(now).value)
t[0],t[-1]
pd.to_datetime(t[0]).strftime('%Y.%m.%d %H:%M:%S'), pd.to_datetime(t[-1]).strftime('%Y.%m.%d %H:%M:%S')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16957279860505667, 'fraction_numerical': 0.08500435919790758, 'mean_word_length': 7.759541984732825, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '384618', 'license': 'MIT', 'n_tokens_mistral': 1080, 'n_tokens_neox': 928, 'n_words': 138, 'path': 'dt.ipynb', 'repo_name': 'loosak/pysnippets', 'size': '2294'}