파이썬 Python/파이썬

[10일차/파이썬] 복습

하나비 HANABI 2023. 1. 6. 17:26

set을 이용한 중복 방지 로직

import random

def is_samenumber(numbers):
    flag = False
    str_num = str(numbers)
    result = set(str_num) # set : 순서 x 중복 x (중복이 있으면 제외하고 넣음)
    if len(result)==4:
        flag=True
    return not flag

pandas로 전처리하여 matplotlib으로 그래프 출력

import pandas as pd
from matplotlib import pyplot as plt

doctor_df = pd.read_csv('./data/12/doctor2.csv')
area = doctor_df['지역'].values # value라는 속성을 꺼내옴. 함수 아님. -> ()붙이면 오류
pro = doctor_df['전문의 수'].values

plt.rc('font', family='Malgun Gothic')
x = list(area)
y = list(pro)
plt.plot(x,y)