Niuke.com Python data analysis exercises (2)

1. There is now a Nowcoder.csv file, which records part of the user data of Niuke.com, including the following fields (the fields are separated by commas): Nowcoder_ID:
User ID
Level: Level
Achievement_value: Achievement value
Num_of_exercise: Brush questions Quantity
Graduate_year: year of graduation
Language: common language
If you want to know who graduated in 2020, and the most commonly used language is Java, please output all their information.

import pandas as pd

data = pd.read_csv("Nowcoder.csv")
pd.set_option("display.width", 200)
pd.set_option("display.max_rows", None)
pd.set_option("display.max_columns", None)

print(data[(data["Language"] == "Java") & (data["Graduate_year"] == 2020)])

2. There is now a Nowcoder.csv file, which records some user data of Niuke.com, including the following fields (the fields are separated by commas): Nowcoder_ID
: User ID
Level: Level
Achievement_value: Achievement value
Num_of_exercise: Brush questions Quantity
Graduate_year: Graduation year
Language: Commonly used languages
​​Now the operation classmate wants you to help to collect all the information of users who use CPP, C, and C#, please output it for him.

import pandas as pd

data = pd.read_csv("Nowcoder.csv", sep=",")
pd.set_option("display.width", 300)  
pd.set_option("display.max_rows", None)  
pd.set_option("display.max_columns", None)

print(data[data["Language"].isin(["CPP", "C", "C#"])])

3. There is now a Nowcoder.csv file, which records part of the user data of Niuke.com, including the following fields (the fields are separated by commas): Nowcoder_ID
: User ID
Level: Level
Achievement_value: Achievement value
Num_of_exercise: Brush questions Quantity
Graduate_year: Graduation year
Language: Commonly used language
Xiaobai who is writing questions wants to know what is the level and achievement value of the boss who has written no less than 500 questions on Niuke.com, can you help him?

import pandas as pd

df = pd.read_csv("Nowcoder.csv", sep=",")
cond = df["Num_of_exercise"] >= 500

print(df[cond][["Level", "Achievement_value"]])

4. There is now a Nowcoder.csv file, which records some user data of Niuke.com, including the following fields (the fields are separated by commas): Nowcoder_ID
: User ID
Level: Level
Achievement_value: Achievement value
Num_of_exercise: Brushing questions Quantity
Graduate_year: Graduation year
Language: Commonly used languages
​​Suppose you graduated in 2018 and want to know which level 7 users of Niuke.com use CPP, and their graduation year is not the same as yours, how to screen?

import pandas as pd

Nowcoder = pd.read_csv("Nowcoder.csv", sep=",")
pd.set_option("display.width", 300) 
pd.set_option("display.max_rows", None)
pd.set_option("display.max_columns", None)

print(Nowcoder.query("Language=='CPP' & Level==7"))

5. There is now a Nowcoder.csv file, which records part of the user data of Niuke.com, including the following fields (the fields are separated by commas): Nowcoder_ID:
User ID
Level: Level
Achievement_value: Achievement value
Num_of_exercise: Brush questions Quantity
Graduate_year: Graduation year
Language: Commonly used languages
​​Just discovered Niuke.com and want to learn programming. I don’t know what language to learn first and what question list to use. Can you help him find Niuke.com’s various languages ​​from this csv file? How many users do you use each?

import pandas as pd

data=pd.read_csv('Nowcoder.csv',sep=',')

print(data['Language'].value_counts())

6. There is now a Nowcoder.csv file, which records some user data of Niuke.com, including the following fields (the fields are separated by commas): Nowcoder_ID
: User ID
Level: Level
Achievement_value: Achievement value
Num_of_exercise: Brush questions Quantity
Graduate_year: Graduation year
Language: Common language
Continuous_check_in_days: The number of recent consecutive check-in days Number_of_submissions
: The number of submissions
Last_submission_time: The date of the last submission
How long has the user logged in continuously, and how long has the shortest user logged in continuously? Please output it for him.

import pandas as pd

Nowcoder = pd.read_csv("Nowcoder.csv", sep=",")

print(Nowcoder["Continuous_check_in_days"].max())
print(Nowcoder["Continuous_check_in_days"].min())

7. There is now a Nowcoder.csv file, which records some user data of Niuke.com, including the following fields (the fields are separated by commas): Nowcoder_ID
: User ID
Level: Level
Achievement_value: Achievement value
Num_of_exercise: Brush questions Quantity
Graduate_year: Graduation year
Language: Common language
Continuous_check_in_days: The number of recent consecutive check-in days
Number_of_submissions: The number of code submissions Last_submission_time: The date of the
last submission of a question
He wants to know how many times the average number of codes submitted by Python users on Niuke.com, please help him find it.

import pandas as pd

data = pd.read_csv("Nowcoder.csv", sep=",")

print(round(data[data["Language"] == "Python"]["Number_of_submissions"].mean(), 1))

8. There is now a Nowcoder.csv file, which records some user data of Niuke.com, including the following fields (the fields are separated by commas): Nowcoder_ID
: User ID
Level: Level
Achievement_value: Achievement value
Num_of_exercise: Brush questions Quantity
Graduate_year: Graduation year
Language: Common language
Continuous_check_in_days: The number of recent consecutive check-in days Number_of_submissions: The number of
code submissions
Last_submission_time: The date of the last submission of questions
Very inactive accounts, so they only counted the part of users whose number of questions was not less than 10.

import pandas as pd

Nowcoder = pd.read_csv("Nowcoder.csv", sep=",")
data = Nowcoder[Nowcoder["Num_of_exercise"] >= 10]
a = data["Level"].median()

print(a.astype("int"))

Guess you like

Origin blog.csdn.net/u013157570/article/details/128970093