Dùng pandas với Seaborn

Giới thiệu trực quan dữ liệu với Seaborn

Content Team

DataCamp

pandas là gì?

  • Thư viện Python cho phân tích dữ liệu
  • Dễ dàng đọc dữ liệu từ csv, txt và các định dạng khác
  • Dữ liệu ở dạng đối tượng DataFrame
Giới thiệu trực quan dữ liệu với Seaborn

Làm việc với DataFrame

import pandas as pd

df = pd.read_csv("masculinity.csv")
df.head()
    participant_id        age    how_masculine    how_important
0                1    18 - 34         Somewhat         Somewhat
1                2    18 - 34         Somewhat         Somewhat
2                3    18 - 34             Very         Not very
3                4    18 - 34             Very         Not very
4                5    18 - 34             Very             Very
Giới thiệu trực quan dữ liệu với Seaborn

Dùng DataFrame với countplot()

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

df = pd.read_csv("masculinity.csv")
sns.countplot(x="how_masculine", data=df)
plt.show()

Biểu đồ đếm cho cột "how_masculine"

Giới thiệu trực quan dữ liệu với Seaborn

10 hàng đầu của DataFrame masculinity

Giới thiệu trực quan dữ liệu với Seaborn

Một DataFrame “không gọn”

Giới thiệu trực quan dữ liệu với Seaborn

Ayo berlatih!

Giới thiệu trực quan dữ liệu với Seaborn

Preparing Video For Download...