아래는 pandas
와 numpy
에서 자주 사용되는 메서드들을 입력 자료형(input type)과 출력 자료형(output type)을 명시하여 표로 정리한 것입니다.
Library | Method | Input Type | Output Type | Description |
---|---|---|---|---|
pandas | DataFrame.loc[] | DataFrame + label or slice | DataFrame or Series | Row/column selection by label. |
pandas | DataFrame.iloc[] | DataFrame + int or slice | DataFrame or Series | Row/column selection by integer position. |
pandas | DataFrame.groupby() | DataFrame + label or list | DataFrameGroupBy | Groups data by one or more columns. |
pandas | DataFrame.mean() | DataFrame | Series or float | Computes mean for each column (or total mean if axis specified). |
pandas | DataFrame.sum() | DataFrame | Series or float | Computes sum for each column (or total sum if axis specified). |
pandas | DataFrame.describe() | DataFrame | DataFrame | Generates descriptive statistics for numeric columns. |
pandas | DataFrame.drop() | DataFrame , label or list | DataFrame | Drops specified rows/columns. |
pandas | DataFrame.apply() | DataFrame , function | Varies (often DataFrame or Series ) | Applies function to each element, column, or row. |
pandas | Series.to_frame() | Series | DataFrame | Converts series to DataFrame with single column. |
pandas | DataFrame.T | DataFrame | DataFrame | Transposes the DataFrame, switching rows and columns. |
pandas | Series.unique() | Series | ndarray | Returns unique values in a Series. |
pandas | DataFrame.fillna() | DataFrame , value or method | DataFrame | Fills missing values. |
numpy | np.mean() | ndarray , list , tuple | float or ndarray | Calculates mean of array elements. |
numpy | np.sum() | ndarray , list , tuple | float , int , or ndarray | Sums array elements along specified axis. |
numpy | np.reshape() | ndarray + tuple (new shape) | ndarray | Reshapes array to specified dimensions. |
numpy | np.arange() | int or float start, stop, step | ndarray | Returns array with evenly spaced values. |
numpy | np.linspace() | float start, stop, num | ndarray | Returns array with linearly spaced values between two numbers. |
numpy | np.random.rand() | int or tuple shape | ndarray | Generates random values in a given shape. |
numpy | np.argmax() | ndarray , axis | int or ndarray | Returns indices of maximum values along an axis. |
numpy | np.concatenate() | tuple or list of arrays | ndarray | Joins multiple arrays along an axis. |
numpy | np.hstack() | tuple or list of arrays | ndarray | Stacks arrays horizontally (column-wise). |
numpy | np.vstack() | tuple or list of arrays | ndarray | Stacks arrays vertically (row-wise). |
numpy | np.where() | condition , x , y | ndarray | Returns elements based on condition. |
이 표는 각 라이브러리에서 자주 쓰이는 메서드의 입력과 출력 자료형을 간단히 정리한 것이며, 실전에서 사용 시에 필요한 파라미터가 더 있을 수 있습니다.