[PYTHON] Summary of what was used in 100 Pandas knocks (# 1 ~ # 32)

Introduction

I am studying ** machine learning ** at university. For review, I tried ** Pandas 100 knocks **. The function you used? I would like to summarize.

Pandas 100 knocks

Click here for details Pandas 100 knocks for Python beginners

Pandas Basics (1 ~ 13)

# 1 Show first 5 lines of DataFrame

df.head()

When specifying the number of lines you want to display

Example: 10 lines

df.head(10)

# 2 Show last 5 lines

df.tail()

# 5 df'fare' sorted in ascending order and displayed

df.sort_values('fare')

Sort in descending order by specifying ** ascending = False **

Data extraction (14 ~ 32)

# 18 Use loc to view the entire df

df.loc[:,:]

Use # 20 loc to display up to the 10th row of the df fare column

df.loc[:10, 'fare']

Extract only data whose age column value of # 25 df is 30 or more

df[df['age'] >= 30]

Extract only data with # 27 df sex column female and age 40 or more

df[(df['sex'] == "female") & (df['age'] >= 40)]

Extract only data whose df sex column is female and age is 40 or more using # 28 query

df.query('sex == "female" & age >= 40')

Display data containing the character string "Mrs" in the name column of # 29 df

df.query('name.str.contains("Mrs")', engine='Python')

# 30 Show only character columns in df

df.select_dtypes(include='object')

# 31 Check the number of elements in each column of df

df.nunique()

Check the elements of the embarked column of # 32 df and the number of occurrences

df['embarked'].value_counts()

Impression that I tried halfway

I felt like I was getting used to Pandas, but when I tried it, my confidence was broken ... It will be a good review, so please try it even if you are accustomed to it. query Very convenient ...

Recommended Posts

Summary of what was used in 100 Pandas knocks (# 1 ~ # 32)
Summary of methods often used in pandas
Grammar summary often used in pandas
Summary of tools used in Command Line vol.8
Summary of tools used in Command Line vol.5
Summary of evaluation functions used in machine learning
Summary of Pandas methods used when extracting data [Python]
2017.3.6 ~ 3.12 Summary of what we did
Basic usage of Pandas Summary
Summary of how to write .proto files used in gRPC
Features of pd.NA in pandas 1.0.0 (rc0)
H29.2.27 ~ 3.5 Summary of what I did
Summary of various operations in Tensorflow
[Anaconda3] Summary of frequently used commands
Summary of frequently used commands of django (beginner)
[Linux] List of Linux commands used in practice
Summary of various for statements in Python
Summary of processes often performed in Pandas 1 (CSV, Excel file related operations)
Summary of stumbling blocks in installing CaboCha
What is on_delete used in django's model?
Summary of modules and classes in Python-TensorFlow2-
Summary of built-in methods in Python list
Processing memos often used in pandas (beginners)
A collection of Numpy, Pandas Tips that are often used in the field
A personal memo of Pandas related operations that can be used in practice
Summary of OSS tools and libraries created in 2016
Summary of how to import files in Python 3
Utilization of recursive functions used in competition pros
Full disclosure of methods used in machine learning
Summary of how to use MNIST in Python
Header shifts in read_csv () and read_table () of Pandas
Fix the argument of the function used in map
Summary of frequently used Python arrays (for myself)
[Python/Django] Summary of frequently used commands (2) <Installing packages>
Summary of frequently used commands (with petit commentary)
Selenium webdriver Summary of frequently used operation methods
Summary of Excel operations using OpenPyXL in Python
Summary of statistical data analysis methods using Python that can be used in business
[Language processing 100 knocks 2020] Summary of answer examples by Python
Used from the introduction of Node.js in WSL environment
Summary of tools needed to analyze data in Python
A miscellaneous summary of what I researched about Ansible
Summary of Linux (UNIX) commands that appeared in Progate
A collection of code often used in personal Python
Summary of pre-processing practices for Python beginners (Pandas dataframe)
A collection of commands frequently used in server management
List of Python code used in big data analysis
pickle To read what was made in 2 series with 3 series
[Python] Summary of table creation method using DataFrame (pandas)
A summary of what I have touched like a blog
Summary of things that were convenient when using pandas
A collection of Excel operations often used in Python
What is a recommend engine? Summary of the types
Summary of date processing in Python (datetime and dateutil)
"Type Error: Unrecognized value type: <class'str'>" in to_datetime of pandas