본문 바로가기

파이썬. 데이터분석112

Seaborn : boxplot, 이상값 제거(1.5IQR) 한번에 여러개 만들기 in list를 이용해서 원하는 데이터만 boxplot import seaborn as sns import matplotlib.pyplot as plt plt.figure(figsize=(5,7)) sns.boxplot(data = mpg, y='hwy') sns.set_style('whitegrid') sns.set_context('paper') #이상값 제거 import numpy as np pct25 = mpg['hwy'].quantile(0.25) pct75 = mpg['hwy'].quantile(.75) iqr = pct75 - pct25 max = pct75 + 1.5 * iqr min = pct25 - 1.5 * iqr mpg['hwy'] = np.where((mpg['.. 2022. 7. 28.
Pandas DataFrame : query, assign, groupby, agg Do it 165~166p assign, agg로 column만들고, groupby로 정리. agg는 평균, 합같은걸 구할때 쓰고 assign은 저런식으로 사용 2022. 7. 26.
Pandas DataFrame : pivot aggfunc 옵션정리 https://datascientyst.com/list-aggregation-functions-aggfunc-groupby-pandas/ List of Aggregation Functions(aggfunc) for GroupBy in Pandas In this article, you can find the list of the available aggregation functions for groupby in Pandas: * count / nunique – non-null values / count number of unique values * min / max – minimum/maximum * first / last - return first or last value per group datasci.. 2022. 7. 25.
DataFrame : query 프로토타입 응용1 조건마다 괄호를 칠수도 있다. in을 사용할 수도 있고, DataFrame 외 변수를 사용할땐 @ 사용 응용2 ++추가 query문 쓰면 조금 짧아지고 직관적으로 바뀜 2022. 7. 24.
가장 심플한 막대그래프 df.plot : 판다스 plot https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.plot.html pandas.DataFrame.plot — pandas 1.4.3 documentation Name to use for the xlabel on x-axis. Default uses index name as xlabel, or the x-column name for planar plots. Changed in version 1.2.0: Now applicable to planar plots (scatter, hexbin). pandas.pydata.org plot은 matplotlib import없이도 사용가능하지만, 도화지 자체가 matplotlib이다(Axes-level) .. 2022. 7. 22.
matplotlib : ax.tick_params stateless https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.tick_params.html matplotlib.axes.Axes.tick_params — Matplotlib 3.5.2 documentation Change the appearance of ticks, tick labels, and gridlines. Tick properties that are not explicitly set using the keyword arguments remain unchanged unless reset is True. Parameters axis{'x', 'y', 'both'}, default: 'both'The axis to which the.. 2022. 7. 21.
matplotlib : 전역설정(global) rcParams 정리 matplotlib 공식사이트 rcParam에 정리되어있다 https://matplotlib.org/stable/tutorials/introductory/customizing.html Customizing Matplotlib with style sheets and rcParams — Matplotlib 3.5.2 documentation Tips for customizing the properties and default styles of Matplotlib. Setting rcParams at runtime takes precedence over style sheets, style sheets take precedence over matplotlibrc files. The matplotlibrc fil.. 2022. 7. 21.
Pandas DataFrame : int를 object로 변환 https://stackoverflow.com/questions/17950374/converting-a-column-within-pandas-dataframe-from-int-to-string Converting a column within pandas dataframe from int to string I have a dataframe in pandas with mixed int and str data columns. I want to concatenate first the columns within the dataframe. To do that I have to convert an int column to str. I've tried to do as stackoverflow.com df['A'] = .. 2022. 7. 21.