Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Operations on scraps #39

Open
a-baughman opened this issue Apr 3, 2019 · 1 comment
Open

Operations on scraps #39

a-baughman opened this issue Apr 3, 2019 · 1 comment

Comments

@a-baughman
Copy link

Hello, I'm using Papermill to create a a directory with output notebooks. In those notebooks I have used sb.glue("Word Count", df_sum, "display") to glue a data frame then using sb.reglue in another. So, in this summary notebook I have the reglue("Word Count") for each of the files in the directory, which then displays ~70 of the same data frames run on different data using Papermill. I would like to take a sum of the values of a certain row across all of the data frames in this summary notebook that uses reglue. Is there a way that you suggest I go about doing this? I am having trouble because when I reglue I am unsure of how I can actually "touch" the data in the reglued data frame to do an operation across many, such as the sum. Thanks in advance!

@MSeal
Copy link
Member

MSeal commented Apr 4, 2019

You can actually access the data that's reglue'd directly via scraps on an individual notebook and notebook_scraps/scraps on a collection of notebooks. Thus depending on how your glue'd data is setup you can iterate on over the scraps and extract the values you wish to sum.

For example to read the first row of each dataframe glued to the same name (glue_df_json in this case) it might look something like this:

sum(df_json[0]["result_column"] for scraps in books.notebook_scraps.values() for df_json in scraps["glue_df_json"])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants