본문 바로가기

Python_Wiki/Python_Library26

library 업데이트에 따른 경고문 + 대체한 입력 방법 구글 콜랩을 사용하면서 마주한 업데이트 경고문을 작성하는 글이다. 1. pandas fillna, replace inplace (2025.6월)e.g. df.fillna('No Data', inplace = True) (inplace는 원본 객체 변경을 위한 함수)에러문: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method. The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on whi.. 2025. 6. 6.
matplotlib: word cloud 워드 클라우드 워드클라우드: 문서의 키워드, 개념 등을 직관적으로 파악하기 위해 핵심단어를 시각화하는 기법from wordcloud import WordCloud: 워드 클라우드 생성 모듈from PIL import Image : 워드 클라우드를 원하는 형태로 그리기 위해 그림을 불러오는 패키지WordCloud().generate(text) : 선언해준 text에서 wordcloud 생성text변환: wordcloud에서 작동하도록 df를 list로 변환시킨 후 str로 2차 변환mask: 단어를 그릴 위치 설정, 흰색 항목은 마스킹 된 것으로 간주cmap = plt.matplotlib.colors.LinearSegmentedColormap.from_list("", ['color1', 'color2'...])plt... 2025. 6. 6.
matplotlib/seaborn: heatmap 히트맵 sns.heatmap()히트맵 예시attributessns.heatmap( fruit_dict, #values to make heatmap with cmap=cmap, #colormap annot=True, #annotation여부 linewidths=.5, #칸 사이사이 줄 두께 fmt='.1%' #퍼센트 표시 포매팅) example: step by step#making df#the amount of packs sold per day in a supermarketfruit_season = { 'Watermelon': [54,1037,515,6,34], 'Strawberry': [936,142,575,2009,56], 'Ora.. 2025. 6. 6.
matplotlib: 꺾은선 그래프 line chart(fill_between) .fill_between()속 안을 채운 그래프는 꺾은선 그래프를 그리고 채우는 것이 아니라 애초에 채운 그래프를 그리게 됨attributesplt.fill_between( # x축을 기준으로 그래프 영역을 채우는 함수 x=df_unstack[1].index, # x value y1=0, y2=df_unstack[1], # 채우기 시작 값, 끝 값, 두 값 사이가 색으로 채워짐 color=[pie_color[2]], alpha=0.9, # 투명도 label = '1' )#.fill_betweenx() : y축을 기준으로 그래프 영역을 채우는 함수 example: step by step #datadict_data2 = { '.. 2025. 6. 5.
matplotlib/seaborn: bar chart 막대 그래프 plt.barplt.figure(figsize=(10,5))plt.plot(x=df['col_name'], y=df['col_name2'])plt.xlabel('col_name')plt.ylabel('col_name2')plt.xticks([2005,2010,2015,2020])plt.ylim(7,10)plt.savefig('figname.png', dpi=600) sns.barplot(data=df, x='열이름', y='열이름')#exampledf = sns.load_dataset('penguins')plt.figure(figsize=(10,5))sns.barplot(data=df, x='species', y='body_mass_g', hue="sex")plt.title('body mass per s.. 2025. 6. 5.
matplotlib: pie chart 파이차트 plt.pie()documentation: https://matplotlib.org/stable/gallery/pie_and_polar_charts/pie_features.htmlfive "generic font family names" (serif, monospace, fantasy, cursive, and sans-serif)reference: fontfamily documentation: https://matplotlib.org/stable/users/explain/text/fonts.htmlpie chart 속성 Pie charts — Matplotlib 3.10.3 documentationDemo of plotting a pie chart. Swap label and autopct text po.. 2025. 6. 5.