[Python] Pandas를 이용하여 직장인의 일주일 간 체력과 행복도 그래프 그리기

2023. 2. 15. 10:02카테고리 없음

import pandas as pd
import matplotlib.pyplot as plt
week = ['Sun','Mon', 'Tue', 'Wed', "Thur", 'Fri', "Sat"]
health_point = [90, 60, 40, 30, 10, 5, 60]
happiness = [60, 40, 20, 30, 60, 80, 90]
data = {
    'health_point': health_point,
    'happiness': happiness
}
df = pd.DataFrame(data, index=week)
# new_column_nm = ['체력', '행복도'] #한글 폰트를 설치해야해서 빼었음
# new_columns = dict(zip(df.columns, new_column_nm))
# df.rename(columns=new_columns, inplace=True)
df.plot(grid=True)
plt.show()

결과물