-
Slow and Steady wins the race
matplotlib, numpy 응용 (sin, cos 그래프 그리기)
실선 스타일의 파란색 sin 그래프 그리기, 파선 스타일의 노란색 cos 그래프 그리기 import numpy as np import pandas as pd import matplotlib.pyplot as plt x = np.linspace(0, 10, 100) # [0, 10] 범위에서 100개의 값 생성 plt.figure() # 새로운 그래프 창을 생성 plt.plot(x, np.sin(x), 'b-') # 실선 스타일로 sin그래프 생성 plt.plot(x, np.cos(x), 'y--') # 파선 스타일로 cos그래프 생성 각각 다른 창에 sin, cos 함수 표현 # subplot()을 활용하여 오른쪽에 보이는 sin, cos 그래프를 그려보세요 plt.figure() plt.subplot(..
2023. 8. 21.
Matplotlib 그래프 (산점도, 막대그래프, 히스토그램, 파이그래프)
산점도(scatter graph) : 두 개의 요소로 이뤄진 데이터 집합의 관계를 그림으로 표현한 것 plt.scatter(x, y [, s=size_n, c=colors, marker='markter_string', alpha=alpha_f) import matplotlib.pyplot as plt height = [178, 165, 188, 160, 187, 185, 165, 176] weight = [72, 67, 65, 64, 90, 85, 53, 64] plt.scatter(height, weight) plt.xlabel('Height(m)') plt.ylabel('Weight(kg)') plt.title('Height & Weight') plt.grid(True) 점 대신 마커 넣기 plt.s..
2023. 8. 21.
Pandas 데이터
Pandas 데이터 통합 1)세로 방향으로 통합하기 : append() import import pandas as pd import numpy as np 데이터 생성 df1 = pd.DataFrame({'Class1': [45, 46, 48, 50], 'Class2': [40, 41, 44, 48]}) df1 df2 = pd.DataFrame({'Class1': [41, 42], 'Class2' : [43, 45]}) df2 행 수가 다른 데이터 결합 df1.append(df2) # 데이터 결합 # 인덱스를 무시 df1.append(df2, ignore_index=True) 열 수가 다른 데이터 통합 df3 = pd.DataFrame({'Class1': [48,38]}) # 데이터 생성 df3 df2.a..
2023. 8. 15.