'Is there a way to fix/delete pars of a df.groupby output?
I want to see if I can remove and move elements from a df.groupby call.
week_df = df.groupby(["day_of_the_week"])['delivery_time'].mean().sort_values(ascending = False).astype(int)
print("The mean delivery time on weekdays and weekends is:", round(week_df), "minutes")
This codeblock gives the following output:
The mean delivery time on weekdays and weekends is: day_of_the_week Weekday 28
Weekend 22
Name: delivery_time, dtype: int64 minutes
Is there a way to delete both "day_of_the_week" in the first line and move "minutes" from the last line to be after both numbers (28 and 22) and delete the final line completely ("Name:, etc.)?
Solution 1:[1]
Try:
>>> print("The mean delivery time on weekdays and weekends is:\n", (week_df.round().astype(int).astype(str)+" minutes").to_string())
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
