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

Replace deprecated applymap() and use two decimal places for formatting #1743

Merged
merged 3 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tock/utilization/analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,5 +243,5 @@ def project_chart_and_table(timecardobject_queryset):
# is more typical, so let's replace the NaNs with zeroes before we
# format the numbers
datatable = datatable.fillna(0)
datatable = datatable.map("{:.0f}".format)
datatable = datatable.map("{:.2f}".format)
return plot_div, datatable
2 changes: 1 addition & 1 deletion tock/utilization/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def get_context_data(self, **kwargs):
"headcount_data": headcount_data_frame.pivot(
index="start_date", values="headcount", columns="organization"
)
.applymap("{:.0f}".format)
.map("{:.0f}".format)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be :.2 for consistency as well?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally made a commit to change it to :.2f but it seems like it's used to display the headcount within the data table on the route utilization/analytics, I may have assumed incorrectly that head count was going to be a whole number. That's an easy enough change if we'd like it to be that way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this one is a whole number and so 0 decimal places is correct.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks y'all! You are right, 0 decimal places is correct here. Merge at will!

.replace("nan", ""),

# we use mark_safe intentionally here because we trust that
Expand Down