xlsx export: emit empty string instead of NaN for sites missing query_time#3013
Open
HrachShah wants to merge 1 commit into
Open
xlsx export: emit empty string instead of NaN for sites missing query_time#3013HrachShah wants to merge 1 commit into
HrachShah wants to merge 1 commit into
Conversation
In the --xlsx branch of main(), the `response_time_s = []` list was initialized four lines above the per-site loop, so the `if response_time_s is None` guard was a dead branch. The `else` always ran and appended `results[site]["status"].query_time` directly. When the per-site query time was None (which happens whenever the request errored out before attaching an `.elapsed` attribute, or whenever the Future was None), None got pushed into the list. The resulting DataFrame.column then contained NaN in those rows, instead of the empty string the --csv branch produces in the same situation, and instead of the string the comment block at the top of the loop implied the xlsx branch was trying to produce. Read the per-site query_time once, fall back to an empty string when it's None, and append that to the list.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The xlsx branch of
main()has a deadif response_time_s is Nonecheck.response_time_sis initialized as a list 4 lines earlier, so it is neverNoneand theelsebranch always runs — appendingstatus.query_timedirectly. When a site hasquery_time = None(the documented default for an unread result), the appendedNoneis written into a pandas column that gets cast to a numeric type byto_excel, producingNaNin the cell instead of the empty string the CSV branch emits for the same case.Fix: Read
status.query_timeinto a localquery_time, then checkif query_time is Noneand append""in the None case, mirroring the existing CSV branch.Verified: Simulated with a list of mixed
[0.123, None, 0.456, None]query_times. Before:[0.123, NaN, 0.456, NaN]. After:[0.123, '', 0.456, '']— matching the CSV branch's output for the same input.