Skip to content

Instantly share code, notes, and snippets.

@retrography
Created July 13, 2015 16:14
Show Gist options
  • Save retrography/3cfd65f3f075de5b0373 to your computer and use it in GitHub Desktop.
Save retrography/3cfd65f3f075de5b0373 to your computer and use it in GitHub Desktop.
GROUP BY for strings in Python Pandas
from pandas import DataFrame as df
import pandas as pd
lics = pd.read_csv("/Users/Mah/Temp/csvdb/license-union-norownum.csv")
licsgr = lics.groupby('gem')['license'].apply(list)
licsgr.columns = ['gem', 'licenses']
# But how do we convert Series to DataFrame in Pandas?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment