Created
November 5, 2014 23:59
-
-
Save wrobstory/60190cc3a052a58f5677 to your computer and use it in GitHub Desktop.
Pandas string methods
This file contains hidden or 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
In [1]: import pandas as pd | |
In [2]: df = pd.DataFrame({"col1": ["one.two", "three.four", "five.six"]}) | |
In [3]: df['col_idx_0'] = df['col1'].str.split('.').str.get(0) | |
In [4]: df['col_idx_1'] = df['col1'].str.split('.').str.get(1) | |
In [5]: df | |
Out[5]: | |
col1 col_idx_0 col_idx_1 | |
0 one.two one two | |
1 three.four three four | |
2 five.six five six |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment