This article and everyone to share is mainly pandasof theGroupByOperationRelated content, come together to look at it, hope to everyone learn pandas helpful.When doing data analysis, our data is generally from the database, then it involvesGroupByoperation. For example, if we want to forecast the electricity tariffs for a residential area for a certain period of time, then the data should be based on communityGroupBy, and then sort by time, hereGroupB
The following for everyone to share a pandas GroupBy group to take the first few lines of the record method, with a good reference value, I hope to be helpful to everyone. Come and see it together.
Directly on the example.
Import Pandas as PD df = PD. DataFrame ({' Class ': [' a ', ' a ', ' B ', ' B ', ' A ', ' a ', ' B ', ' C ', ' C '], ' score ': [3,5,6,7,8,9
'] = df_final.apply (convert_state, Axis=1)
Df_final.tail ()
I think it's cool. We have developed a very simple process to intelligently clean up the data. Obviously, it's no big deal when you have 15 lines of data. But what if it's 15000 lines? In Excel you have to do some manual cleanup.Subtotal
In the last section of this article, let's do some subtotals by state (subtotal).
In Excel, we'll use the Subtotal tool to do this.
The output is as follows:
Creating subtotals in
MySQL Tutorial: the usage of GroupBy is now back to the function. Remember to use the SUM command to calculate all Sales (turnover! What should we do if we want to calculate the turnover (sales) of each store (store_name? In this case, we need to do two things: first, we need to select both store_name and Sales columns. Second, we need to confirm that all sales are calculated separately based on each store_
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.