Skip to content

Instantly share code, notes, and snippets.

@u1and0
Created September 6, 2016 07:36
Show Gist options
  • Save u1and0/84c8c37219bc61664a56036f333e9e34 to your computer and use it in GitHub Desktop.
Save u1and0/84c8c37219bc61664a56036f333e9e34 to your computer and use it in GitHub Desktop.
import pandas as pd
import numpy as np
df=pd.DataFrame(np.arange(9).reshape(3,3))
df
#[Out]# 0 1 2
#[Out]# 0 0 1 2
#[Out]# 1 3 4 5
#[Out]# 2 6 7 8
df.index=range(100,103)
df
#[Out]# 0 1 2
#[Out]# 100 0 1 2
#[Out]# 101 3 4 5
#[Out]# 102 6 7 8
df.reindex(range(100,103))
#[Out]# 0 1 2
#[Out]# 100 NaN NaN NaN
#[Out]# 101 NaN NaN NaN
#[Out]# 102 NaN NaN NaN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment