Report DFs now get combined as a flattened list #175
Report DFs now get combined as a flattened list #175Matt-From-AnswerRocket merged 1 commit intomainfrom
Conversation
|
|
||
| df_dicts = result.chat_entry.answer.report_results[0].gzipped_dataframes_and_metadata | ||
| df_dicts = [report.gzipped_dataframes_and_metadata for report in result.chat_entry.answer.report_results if report.gzipped_dataframes_and_metadata] | ||
| # flatten |
There was a problem hiding this comment.
I know this could be a single list comp, but I think these are hard enough to read as is, so I went with 2
There was a problem hiding this comment.
Pull request overview
This PR fixes an index out of bounds error in the get_dataframes_for_entry method by collecting dataframes from all report results instead of only accessing the first report. The solution uses list comprehension with filtering and flattening to combine all dataframes into a single flat list.
Key Changes:
- Replaced direct indexing
[0]with list comprehension to iterate through all reports - Added filtering to exclude reports without dataframe metadata
- Implemented list flattening to convert nested list structure into a single flat list
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| df_dicts = result.chat_entry.answer.report_results[0].gzipped_dataframes_and_metadata | ||
| df_dicts = [report.gzipped_dataframes_and_metadata for report in result.chat_entry.answer.report_results if report.gzipped_dataframes_and_metadata] | ||
| # flatten |
There was a problem hiding this comment.
The comment "flatten" is too brief and doesn't explain what's being flattened or why. Consider expanding this to clarify that we're flattening the nested list of dataframes from multiple reports into a single flat list.
| # flatten | |
| # Flatten the nested list of dataframes and metadata dictionaries from multiple reports | |
| # into a single flat list for easier processing. |
This resolves the index out of bounds error on the get_dataframes_for_entry method by combining and flattening all DF results. It also means that we now get DFs for ALL reports instead of just the first one.