Skip to content

Instantly share code, notes, and snippets.

@simonespa
Created December 13, 2023 15:15
Show Gist options
  • Select an option

  • Save simonespa/61b4ebce3c28c6a4e575ebafc727be2b to your computer and use it in GitHub Desktop.

Select an option

Save simonespa/61b4ebce3c28c6a4e575ebafc727be2b to your computer and use it in GitHub Desktop.
Dask Snippet
##
# This method is quite slow for a large number of files (GBs)
# Just wanted to save some parts of the entire snippet for reference
# of some useful stuff like picking a row from a Dask dataframe
# and appending it to a Pandas Dataframe.
for id in unique_ids:
# select all the rows across the partitions for the specified ID
subset = catalogue[catalogue.id == id]
# select only the one row with the latest date and time (max timestamp)
subset = subset[subset.timestamp == subset.timestamp.max()]
# append the selected row to the final dataset
final_catalogue.loc[final_catalogue.shape[0]] = list(subset.to_dask_array().compute())[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment