본문 바로가기

분류 전체보기273

7/16 나도코딩 데이터분석 끝 완강했다. matplotlib 골때리네 stateful(plt) 과 stateless(fig, ax)의 차이에 대해 배웠다. fig,ax문법은 정보가 별로 없는데 2022. 7. 16.
matplotlib : ax. plt. 문법차이 https://wooono.tistory.com/297 [Matplotlib] figure, subplot 차이 matplotlib.pyplot.figure reference https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.html example import matplotlib.pyplot as plt # figure 크기 설정 plt.figure(figsize=(15,7)) # grid 설정 p.. wooono.tistory.com matplotlib.pyplot plt.이후 메서드 https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.html matplotlib.pyplot — Matplot.. 2022. 7. 16.
해결중..) matplotlib : ax. 와 plt. 의 차이. 엑셀 그래프 공부할 때는 정말 편했다. 그래프 그리는 방법이 한가지로 통일되어있으니 그냥 책보고 따라하면서 공부하면 그만이다. 머리아플일도 없었는데 파이썬을 공부하면서는 라이브러리도 한개가 아닌데 심지어 같은 matplotlib을 쓰는데 누구는 plt.xlabel~ 이런식으로하고 누구는 ax.set_~~이런식으로 하고 왜 이렇게 할까 궁금해서 찾아봤다 https://hwi-doc.tistory.com/entry/matplotlib-%EC%99%84%EB%B2%BD-%EC%A0%95%EB%A6%AC matplotlib 완벽 정리 데이터 분야 공부를 시작할때 가장 먼저 만나는 세 가지 라이브러리를 꼽자면 numpy, pandas, matplotlib 입니다. 오늘은 그 중 matplotlib 에 대해서 정리.. 2022. 7. 16.
pd.read_excel : 경로는 고정, 파일명만 바꾸기 fileroute 경로는 고정시켜놓고 filename만 바꿔서하면 실무에서 편함 2022. 7. 16.
matplotlib : plt.subplot 여러 그래프 동시에 보여주기 2 fig,ax 튜플보다 그래프 설정하는 문법이 좀 더 익숙해서 좋다. plt.figure(figsize=(20,20)) plt.subplot(2,2,1) plt.bar(index, dff_1['출고수량']) plt.title('요일별', fontsize=30) plt.xticks(index, label, fontsize=15) plt.subplot(2,2,2) plt.bar(index, dff_2['출고수량']) plt.title('요일별', fontsize=30) plt.xticks(index, label, fontsize=15) plt.subplot(2,2,3) plt.bar(index, dff_3['출고수량']) plt.title('요일별', fontsize=30) plt.xticks(index, l.. 2022. 7. 14.
matplotlib : 산점도 scatter scatter 프로토타입 sizes = df['학년'] plt.figure(figsize=(10,10)) plt.scatter(df['영어'], df['수학'], s= sizes * 500, c = df['학년'], cmap='Set3', alpha=0.9) plt.xlabel('영어 점수') plt.ylabel('수학 점수') plt.colorbar(ticks=[1, 2, 3], label='학년', shrink=0.8, orientation ='horizontal') 2022. 7. 14.
Numpy : np.where / if 함수역할 df['sex'] = np.where(df['sex'] == 3, np.nan, df['sex']) df 예시1 mpg['grade2'] = np.where(mpg['total'] >= 30, 'A', np.where(mpg['total'] >= 25, 'B',np.where(mpg['total'] >= 20, 'C', 'D'))) mpg['size'] = np.where((mpg['category'] == 'compact') | (mpg['category'] == 'subcompact') | (mpg['category'] == '2seater'), 'small', 'large') mpg['size'] = np.where(mpg['category'].isin(['compact','subcompact','.. 2022. 7. 14.
matplotlib : 원그래프(파이그래프) values = [30, 25, 20, 13, 10, 2] labels = ['Python', 'Java', 'Javascript', 'C#', 'C/C++', 'ETC'] plt.pie(values, labels= labels, autopct='%.2f%%', counterclock=False) plt.show() values = [30, 25, 20, 13, 10, 2] labels = ['Python', 'Java', 'Javascript', 'C#', 'C/C++', 'ETC'] explode = [0.05] * 6 plt.pie(values, labels= labels, autopct='%.2f%%', explode=explode, counterclock=False) plt.legend() pl.. 2022. 7. 13.