Last active
August 22, 2017 19:34
-
-
Save lockefox/2e6f543216cd7133caf6890faf48aa23 to your computer and use it in GitHub Desktop.
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
data_columns = ['killID', 'solarSystemID', 'killTime', 'moonID'] | |
pivot_column = 'items' | |
index_column = 'killID' | |
## Make source DataFrame ## | |
raw_df = pd.DataFrame(raw_data) | |
## Row-by-row rotate and append desired data ## | |
result_df = None | |
for row in raw_df.itertuples(): | |
row_df = pd.DataFrame(getattr(row, pivot_column)) | |
row_df[index_column] = getattr(row, index_column) | |
result_df = pd.concat([result_df, row_df], axis=0, ignore_index=True) | |
## Merge source/pivot together ## | |
result_df = result_df.join(raw_df, index_column, lsuffix='_') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment