Created
September 6, 2016 07:36
-
-
Save u1and0/84c8c37219bc61664a56036f333e9e34 to your computer and use it in GitHub Desktop.
pandas indexとreindex ref: http://qiita.com/u1and0/items/5e59fb7b0dfd452f1050
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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