<jupyter_start><jupyter_text>Working with Indexes in Time Series<jupyter_code>import pandas as pd ; import numpy as np
date=pd.date_range(
    start="2018",end="2019", freq="BM")
ts=pd.Series(
    np.random.randn(len(date)),index=date)
ts
ts.index
ts[:5].index<jupyter_output><empty_output><jupyter_text>Reading a Time Series Data Set<jupyter_code>fb=pd.read_csv("FB.csv")
fb.head()<jupyter_output><empty_output><jupyter_text>Converting date to index<jupyter_code>fb.dtypes
fb=pd.read_csv(
    "FB.csv", parse_dates=["Date"])
fb=pd.read_csv(
    "FB.csv", 
    parse_dates=["Date"], 
    index_col="Date")
fb.index
fb.head()
fb["2019-06"]<jupyter_output><empty_output><jupyter_text>Working with Indexes<jupyter_code>fb["2019-06"].Close.mean()
fb["2019-07-05":"2019-07-10"]
t=pd.to_datetime("7/22/2019")
t
fb.loc[fb.index>=t,:]<jupyter_output><empty_output><jupyter_text>Dating the Data Set<jupyter_code>fb1=pd.read_csv("FB-no-date.csv",sep=";")
fb1.head()
dates=pd.date_range(start="03/01/2019", 
                    end="03/29/2019", 
                    freq="B") 
dates
fb1.set_index(dates,inplace=True)
fb1.head()
fb1.index<jupyter_output><empty_output><jupyter_text>Visualizing Time Series Data<jupyter_code>%matplotlib inline
fb1.Close.plot()
fb1.asfreq("H",method="pad").head()
fb1.asfreq("W", method="pad")
fb1.asfreq("H", method="pad")
z=pd.date_range(start="3/1/2019", 
                periods=60 , freq="B")
z
z=pd.date_range(
    start="3/1/2019", periods=30, freq="H")
z
ts=pd.Series(
    np.random.randint(1,10,len(z)),index=z)
ts.head()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18722327640733713, 'fraction_numerical': 0.055660974067046176, 'mean_word_length': 5.789699570815451, 'pattern_counts': {'":': 1, '<': 25, '<?xml version=': 0, '>': 26, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '532645', 'license': 'MIT', 'n_tokens_mistral': 717, 'n_tokens_neox': 657, 'n_words': 79, 'path': 'jupyter/pandas-tut/24-Work with Index in Time Series.ipynb', 'repo_name': 'Sesughter01/ds-march-univel', 'size': '1581'}