반응형
Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

비전공개미 개발노트

[Python] seaborn 기본연습 본문

프로그래밍/Python

[Python] seaborn 기본연습

비전공개미 2022. 12. 1. 19:57
반응형
SMALL
# sns.py
import seaborn as sns
import matplotlib.pyplot as plt 
import numpy as np
import pandas as pd

iris = sns.load_dataset("iris")
titanic = sns.load_dataset("titanic")
tips = sns.load_dataset("tips")
flights = sns.load_dataset("flights")

x = iris.petal_length.values
# # sns.rugplot(x)
# sns.rugplot(data=iris, x="petal_length")
# sns.kdeplot(x)

# sns.distplot(x, kde=True, rug=True)
# sns.histplot(x, kde=True)

# sns.countplot(x="class", data=titanic)
# sns.countplot(data=tips, x="day")
# plt.hist(tips.day)

# sns.jointplot(x="sepal_length", y="sepal_width", data=iris)
# sns.jointplot(x="petal_length", y="petal_width", data=iris, kind="kde")
# plt.scatter(iris.petal_length, iris.petal_width, alpha=0.5)
# plt.title("IRIS")
# plt.suptitle("IRIS")


# sns.pairplot(iris)
# sns.pairplot(iris, hue="species", markers=["o", "d", "s"])

# print(titanic.head())
tsize = titanic.pivot_table(index="class", columns="sex", aggfunc="size")
# print(tsize)
# sns.heatmap(tsize, annot=True, fmt="d", cmap=sns.light_palette("gray", as_cmap=True))

# sns.barplot(x="day", y="total_bill", data=tips)
# sns.barplot(x="day", y="total_bill", data=tips, hue="sex")  #hue - 기준값

# sns.boxplot(x="day", y="total_bill", data=tips)
# sns.boxplot(x="day", y="total_bill", data=tips, hue="sex")

# sns.violinplot(x="day", y="total_bill", data=tips)
# sns.violinplot(x="day", y="total_bill", data=tips, hue="sex")
# sns.violinplot(x="day", y="total_bill", data=tips, hue="sex", split=True)   #split - 하나를 반으로 나누어서 보여줌

# sns.stripplot(x="day", y="total_bill", data=tips)
# sns.stripplot(x="day", y="total_bill", data=tips, hue="sex")
# sns.stripplot(x="day", y="total_bill", data=tips, hue="sex", dodge=True, jitter=False)    #dodge - 양쪽으로 나누어서 보여줌

# sns.swarmplot(x="day", y="total_bill", data=tips)
# sns.swarmplot(x="day", y="total_bill", data=tips, hue="sex")
# sns.swarmplot(x="day", y="total_bill", data=tips, hue="sex", dodge=True)

# sns.catplot(x="age", y="sex", data=titanic, hue="survived")
# sns.catplot(x="age", y="sex", data=titanic, hue="survived", kind="violin", split=True)
# sns.catplot(x="age", y="sex", data=titanic, hue="survived", kind="box")

# sns.boxplot(x="tip", y="day", data=tips, whis=np.inf)
# sns.stripplot(x="tip", y="day", data=tips, jitter=True, color="0.4", alpha=0.5)
# sns.violinplot(x="tip", y="day", data=tips, inner=None, alpha=0.5)
# sns.swarmplot(x="tip", y="day", data=tips, color="0.9", alpha=0.5)

# plt.style.use("ggplot")
# sns.set_style("ticks")
# sns.set_style("darkgrid")
# sns.set_style("whitegrid")
# sns.boxplot(x="tip", y="day", data=tips, whis=np.inf)
#
#
#
# plt.show()







# def hap(a=0, b=0, c=0):      #매개변수 argument parameter
#     return a + b + c
# print(hap(5, 2))
# print(hap(a=10, c=20))
# print(hap(c=10, b=20))

# variable argument
# def hap(*args):
#     sum = 0
#     for i in args:
#         sum += i
#     return sum
# print(hap(2, 5, 7))
# print(hap(2, 5, 7, 9))
# print(hap(3))


# def hap(*args, **params):   # ** 키워드 인수 사전
#     sum = 0
#     for i in args:
#         sum += i
#     print("합 : " + str(sum))
#
#     for key, value in params.items():
#         print(key + " : " + str(value))
#
# hap(10, 20, 30, a=40, b=50)     #키워드 인수 (10, 20, 30 - *args로 / a=40, b=50 - **params로 이동)
# # 섞어서는 사용 안됨
# # hap(a=40, b=50, 10, 20, 30)
# # hap(10, 20, a=10, b=20, 30)


a = np.random.sample(10) * 100
print(a)
반응형
LIST

'프로그래밍 > Python' 카테고리의 다른 글

[Python] matplotlib.pyplot, seaborn 기본연습  (0) 2022.12.01
[Python] Pandas 기본출력  (0) 2022.12.01
[Python] Numpy 기본출력  (0) 2022.12.01
python 5일차 - 성적 관리 프로그램  (0) 2022.09.02
python 5일차 - NumPy  (0) 2022.09.02
Comments