Split text column into multiple new columns

See: https://github.com/dennisbakhuis/Tutorials/blob/master/B_Pandas_tips/2-%20Split%20text%20column%20into%20multiple%20new%20columns.ipynb

import pandas as pd

df = pd.DataFrame([
    {'path': 'train/data_shard_1.csv'},
    {'path': 'train/data_shard_2.csv'},
    {'path': 'train/data_shard_3.csv'},
    {'path': 'test/data_shard_1.csv'},
    {'path': 'test/data_shard_2.csv'},
])

df = (df
    .join(df
        .loc[:, 'path']
        .str.split('/', expand=True)
        .rename(columns={0: 'folder', 1: 'filename'})
    )
)

df
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}