Skip to content

Instantly share code, notes, and snippets.

@jtrive84
Created August 20, 2024 14:58
Show Gist options
  • Save jtrive84/ea09f1ebb35253e331bf059ab355b548 to your computer and use it in GitHub Desktop.
Save jtrive84/ea09f1ebb35253e331bf059ab355b548 to your computer and use it in GitHub Desktop.
Groupy into list in Pandas
# Create a DataFrame that takes a dataset of 50k State - County - ZIp combinations
# to a table of ~3k reocrds keyed by County, with a list column of zipcodes.
ggck = dfz2c.groupby(["STATE", "FIPS", "County"], as_index=False)["ZIP"].apply(list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment