<jupyter_start><jupyter_text>[View in Colaboratory](https://colab.research.google.com/github/takeo-asai/Practice-Python-Data-Science/blob/master/section4/lecture17.ipynb)<jupyter_code>import numpy as np
import pandas as pd
from pandas import Series, DataFrame
from numpy.random import randn
ser1 = Series([1,2,3,4], index=['A','B','C','D'])
ser1
ser2 = ser1.reindex(['A','B','C','D','E','F'])
ser2
ser2.reindex(['A','B','C','D','E','F','G'], fill_value=0)
ser3 = Series(['USA','Mexico','Canada'], index=[0,5,10])
ser3
ser3.reindex(range(15), method='ffill')
dframe = DataFrame(randn(25).reshape(5,5), index=['A','B','D','E','F'], columns=['col1','col2','col3','col4','col5'])
dframe
new_index = ['A','B','C','D','E','F']
dframe2 = dframe.reindex(new_index)
dframe2
new_columns = ['col1','col2','col3','col4','col5', 'col6']
dframe.reindex(columns=new_columns)
dframe.ix[new_index, new_columns]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2513542795232936, 'fraction_numerical': 0.04333694474539545, 'mean_word_length': 10.268292682926829, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '552448', 'license': 'MIT', 'n_tokens_mistral': 385, 'n_tokens_neox': 368, 'n_words': 50, 'path': 'section4/lecture17.ipynb', 'repo_name': 'takeo-asai/Practice-Python-Data-Science', 'size': '923'}