<jupyter_start><jupyter_text>Series and DataFrame can directly also support the time component as data itself.<jupyter_code>d=pd.date_range(start='1/1/2018', end='1/08/2018')
d
ts = pd.Series(d)
ts
ts = pd.Series(index=d)
ts
ts = pd.Series(range(len(d)), index=d)
ts
pd.date_range(start='1/1/2018', periods=5, freq='M')
pd.Timestamp.min #584 years:
pd.Timestamp('2012-05-01')<jupyter_output><empty_output><jupyter_text>Converting to timestamps  To convert a Series or list-like object of date-like objects e.g. strings, epochs, or a mixture, you can use the to_datetime function. When passed a Series, this returns a Series (with the same index), while a list-like is converted to a DatetimeIndex:<jupyter_code>pd.to_datetime(pd.Series(['Jul 31, 2009', '2010-01-10', None]))
pd.to_datetime(['2005/11/23', '2010.12.31'])
pd.DatetimeIndex(['2018-01-01', '2018-01-03', '2018-01-05'])<jupyter_output><empty_output><jupyter_text>Providing a format argument<jupyter_code>pd.to_datetime('2010/11/12', format='%Y/%m/%d')<jupyter_output><empty_output><jupyter_text>Assembling datetime from multiple DataFrame columns<jupyter_code>df = pd.DataFrame({
    'year': [2015, 2016],
    'month': [2, 3],
    'day': [4, 5],
    'hour': [2, 3]
})
pd.to_datetime(df)<jupyter_output><empty_output><jupyter_text>Generating ranges of timestamps<jupyter_code>start = datetime.datetime(2011, 1, 1)

end = datetime.datetime(2012, 1, 1)

index = pd.date_range(start, end)

index
pd.date_range(start, periods=1000, freq='M')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15979043876882776, 'fraction_numerical': 0.08055009823182711, 'mean_word_length': 6.527093596059113, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '538091', 'license': 'MIT', 'n_tokens_mistral': 658, 'n_tokens_neox': 573, 'n_words': 125, 'path': 'cleaning data in python/Tidying data for analysis/04.2 Time series .ipynb', 'repo_name': 'nazmusshakib121/Importing-Cleaning-Data-with-Python', 'size': '1527'}