pandas, numpy 자주 사용하는 메서드

Dev.Hammy·2024년 11월 7일
0

Etc

목록 보기
21/21

아래는 pandasnumpy에서 자주 사용되는 메서드들을 입력 자료형(input type)과 출력 자료형(output type)을 명시하여 표로 정리한 것입니다.

LibraryMethodInput TypeOutput TypeDescription
pandasDataFrame.loc[]DataFrame + label or sliceDataFrame or SeriesRow/column selection by label.
pandasDataFrame.iloc[]DataFrame + int or sliceDataFrame or SeriesRow/column selection by integer position.
pandasDataFrame.groupby()DataFrame + label or listDataFrameGroupByGroups data by one or more columns.
pandasDataFrame.mean()DataFrameSeries or floatComputes mean for each column (or total mean if axis specified).
pandasDataFrame.sum()DataFrameSeries or floatComputes sum for each column (or total sum if axis specified).
pandasDataFrame.describe()DataFrameDataFrameGenerates descriptive statistics for numeric columns.
pandasDataFrame.drop()DataFrame, label or listDataFrameDrops specified rows/columns.
pandasDataFrame.apply()DataFrame, functionVaries (often DataFrame or Series)Applies function to each element, column, or row.
pandasSeries.to_frame()SeriesDataFrameConverts series to DataFrame with single column.
pandasDataFrame.TDataFrameDataFrameTransposes the DataFrame, switching rows and columns.
pandasSeries.unique()SeriesndarrayReturns unique values in a Series.
pandasDataFrame.fillna()DataFrame, value or methodDataFrameFills missing values.
numpynp.mean()ndarray, list, tuplefloat or ndarrayCalculates mean of array elements.
numpynp.sum()ndarray, list, tuplefloat, int, or ndarraySums array elements along specified axis.
numpynp.reshape()ndarray + tuple (new shape)ndarrayReshapes array to specified dimensions.
numpynp.arange()int or float start, stop, stepndarrayReturns array with evenly spaced values.
numpynp.linspace()float start, stop, numndarrayReturns array with linearly spaced values between two numbers.
numpynp.random.rand()int or tuple shapendarrayGenerates random values in a given shape.
numpynp.argmax()ndarray, axisint or ndarrayReturns indices of maximum values along an axis.
numpynp.concatenate()tuple or list of arraysndarrayJoins multiple arrays along an axis.
numpynp.hstack()tuple or list of arraysndarrayStacks arrays horizontally (column-wise).
numpynp.vstack()tuple or list of arraysndarrayStacks arrays vertically (row-wise).
numpynp.where()condition, x, yndarrayReturns elements based on condition.

이 표는 각 라이브러리에서 자주 쓰이는 메서드의 입력과 출력 자료형을 간단히 정리한 것이며, 실전에서 사용 시에 필요한 파라미터가 더 있을 수 있습니다.

0개의 댓글