<jupyter_start><jupyter_text>Reindexing and altering labelshttps://pandas.pydata.org/pandas-docs/stable/basics.htmlbasics-reindexingreindex() is the fundamental data alignment method in pandas. It is used to implement nearly all other features relying on label-alignment functionality. To reindex means to conform the data to match a given set of labels along a particular axis. This accomplishes several things:    - Reorders the existing data to match a new set of labels    - Inserts missing value (NA) markers in label locations where no data for that label existed    - If specified, fill data for missing labels using logic (highly relevant to working with time series data) Example from pandas documentation https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.reindex.html<jupyter_code>index = ['Firefox', 'Chrome', 'Safari', 'IE10', 'Konqueror']
df = pd.DataFrame({
    'http_status': [200,200,404,404,301],
    'response_time': [0.04, 0.02, 0.07, 0.08, 1.0]},
    index=index)
df
new_index= ['Safari', 'Iceweasel', 'Comodo Dragon', 'IE10', 'Chrome']
new_index
df
df.reindex(new_index)<jupyter_output><empty_output><jupyter_text>df.reindex() - Time Series Example<jupyter_code>>>> date_index = pd.date_range('1/1/2010', periods=6, freq='D')
>>> df2 = pd.DataFrame({"prices": [100, 101, np.nan, 100, 89, 88]},
...                    index=date_index)
>>> df2
>>> date_index2 = pd.date_range('12/29/2009', periods=10, freq='D')
>>> df2.reindex(date_index2)
>>> df2.reindex(date_index2, method='bfill', limit=2)<jupyter_output><empty_output><jupyter_text>df.align with another object<jupyter_code>import matplotlib.pyplot as plt
x1 = np.arange(1,11)
x2 = np.arange(3,12)
y1 = np.sin(x1)
y2 = np.sin(x2)
s1 = pd.Series(y1, index=x1)
s2 = pd.Series(y2, index=x2)
display(s1)
display(s2)
s1a, s2a = s1.align(s2)
display(s1a)

display(s2a)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13915343915343914, 'fraction_numerical': 0.051322751322751325, 'mean_word_length': 5.367003367003367, 'pattern_counts': {'":': 1, '<': 13, '<?xml version=': 0, '>': 31, 'https://': 2, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '442283', 'license': 'MIT', 'n_tokens_mistral': 736, 'n_tokens_neox': 682, 'n_words': 174, 'path': 'Virtual Meetup - 2017.11.18/Extra Examples/Pandas Reindex and Align.ipynb', 'repo_name': 'MichaelJMath/quant-finance-meetup-sfl', 'size': '1890'}