Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Case Analysis of python data

Shulou Source: shulou.com Published: 2022-05-31 10:40:22 09月22日 Update

In this article, the editor introduces in detail the "case analysis of python data", with detailed contents, clear steps and proper handling of details. I hope that this "case analysis of python data" article can help you solve your doubts.

data

Assuming that our data is like this, with no anomalies and no missing values, let's practice exploratory data analysis with Pandas through a few questions.

Yearnamesalarytitle2001aa1500first2002bb4300first2003cc7000second2001dd5000third question 1: what is the maximum salary?

We read the data and named it df.

Import pandas as pd

Df ['salary'] .max ()

Similarly, lowest (min), average (mean).

Question2: what is bb's salary?

Suddenly thought of SQL, is it an one-sentence thing, select...from...where... Of course, our pandas is also a matter of one sentence:

Df [df ['name'] =' bb'] ['salary'] question 3: who is the person with the highest income?

Then we will locate the line with the highest income.

Df [df ['salary'] = = df [' salary'] .max ()]

# or

Df.loc [df ['salary'] .idxmax ()] question 4: average annual income for all employees?

Is it natural to think of grouping, group by?

Df.groupby ('year'). Mean () [' salary'] question 5: how many job titles are there?

I use the nunique () function here. I had a small partner who communicated with me and found that I didn't understand the difference between the nunique () function and the unique () function.

Df ['title'] .nunique () has read this article "python data instance Analysis". If you want to master the knowledge points of this article, you still need to practice and use it. If you want to know more about related articles, please follow the industry information channel.

Tags: Data problem analysis example case analysis maximum function income article one sentence thing content salary proper lowest natural in between usage several questions employee Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Huawei Apple vpn Docker