생활정보/파이썬 개발

파이썬 데이터분석 필수 라이브러리 TOP6

뿌부부 2023. 7. 5.
반응형

파이썬에는 데이터 분석 시 필요한 필수 라이브러리(패키지)가 몇 개 있다. 

오늘은 파이썬 필수 라이브러리를 알아보고 각각의 특징과 기능을 소개하려고 한다.

 

<파이썬 필수 라이브러리 리스트>

1. Pandas
2. Numpy 
3. Scipy

4. Matplotlib

5. Seaborn
6. Scikit-learn

 

1. Pandas 

Pandas는 데이터 분석의 가장 기초가 되는 라이브러리로, 데이터를 불러오는 것부터 데이터 저장, 데이터프레임 생성, 편집, 수정, 분석 등 다양한 기능을 제공한다. Python을 처음 수학할 때 가장 기초적으로 설치 및 학습하는 라이브러리가 바로 이 Pandas이다. Pandas의 주요 기능(function)으로는 DataFrame, merge, concat, read_table, read_csv, groupby, pivot, index 등이 있다. 사실상 데이터 분석에 필요한 거의 대부분의 기능들을 제공한다고 보면 된다. 

아래 Pandas 공식 홈페이지에서 function에 대한 설명을 제공한 documentation을 찾아볼 수 있다.

 

API reference — pandas 2.0.3 documentation

This page gives an overview of all public pandas objects, functions and methods. All classes and functions exposed in pandas.* namespace are public. Some subpackages are public which include pandas.errors, pandas.plotting, and pandas.testing. Public functi

pandas.pydata.org

 

 

2. Numpy

Pandas가 분석에 사용하는 데이터형태가 주로 우리가 엑셀창에서 다루는 것과 같은 형태의 데이터프레임(dataframe)이라면, Numpy는 어레이(array)데이터를 사용한 분석을 돕는 라이브러리다. 어레이(array)는 순차적으로 배열된 데이터 형태를 뜻한다. 주로 하나의 변수에 여러 숫자 데이터가 담겨 있을 때 사용하는 데이터형태이다. Numpy는 이 같은 배열형 수치 데이터 분석을 하는 데 사용된다.

Numpy에서 주로 사용되는 기능(function)은 ndarray, dtype, np.array, np.arange, np.linspace 등이 있다. 아래 Numpy 공식 홈페이지에서 function에 대한 기능과 초보자를 위한 튜토리얼을 제공한다.

 

 

NumPy documentation — NumPy v1.25 Manual

The reference guide contains a detailed description of the functions, modules, and objects included in NumPy. The reference describes how the methods work and which parameters can be used. It assumes that you have an understanding of the key concepts.

numpy.org

 

 

3. Scipy

Scipy는 통계 분석을 위한 알고리즘을 제공하는 라이브러리로, 최적화, 미분, 적분, 고유값 문제 등 다양한 종류의 통계 문제 해결에 사용된다. 주로 Scipy의 stats라는 서브패키지가 자주 사용되며, 이 서브패키지를 통해 correlation analysis, t-test, 분포의 정규성 테스트 등 다양한 통계 작업이 가능하다. 아래 Scipy 공식 사이트에 각각의 function과 통계적 설명이 제공되어 있다.

 

 

SciPy documentation — SciPy v1.11.1 Manual

Want to build from source rather than use a Python distribution or pre-built SciPy binary? This guide will describe how to set up your build environment, and how to build SciPy itself, including the many options for customizing that build.

docs.scipy.org

 

4. Matplotlib

MAtplotlib은 통계 데이터 시각화 (visualization)에 사용되는 라이브러리다. Plot, Bar chart, Scatter, Histogram, Boxplot, Pie 등 통계 데이터 시각화에 필요한 거의 모든 figure를 생성할 수 있도록 하는 라이브러리이다. Interactive visualization과 3D chart 또한 제공된다. 데이터 시각화는 데이터 분석의 결과전달에 있어서 굉장히 중요한 스킬이기 때문에 데이터 분석가 업무를 수행하기 위해서는 해당 라이브러리를 잘 활용하는 방법을 배워두는 게 좋다. 

 

 

Matplotlib documentation — Matplotlib 3.7.1 documentation

Matplotlib 3.7.1 documentation Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. Installation Install using pip: Install using conda: conda install -c conda-forge matplotlib Further details are a

matplotlib.org

 

5. Seaborn

Seaborn 역시 통계 데이터 시각화 라이브러리로, 위의 Matplotlib에 기반하고 있다. 개인적으로 Matplotlib에서 제공하는 데이터 시각화 툴은 기능은 좋으나 심미성(?)이 조금 떨어지는 느낌이 있는데, Seaborn은 그런 단점을 보완하는 라이브러리이다. 데이터 시각화 방식은 똑같지만, 제공되는 figure가 훨씬 더 아름답다.

 

 

seaborn: statistical data visualization — seaborn 0.12.2 documentation

seaborn: statistical data visualization

seaborn.pydata.org

 

6. Scikit-learn

Scikit-learn은 머신러닝에 관한 가장 최적의 라이브러리이다. 머신러닝에서 사용되는 Supervised learning, unsupervised learning, semi-supervised learning 등 다양한 기법들에 대한 기능이 제공되고 있으며, 여러 형태의 inferential data analysis, predictive analysis 기법을 제공하고 있다. 회귀 모델에 대한 기능들이 굉장히 편리하고 뛰어나서 머신러닝 뿐만 아니라 회귀 분석을 주로 하는 분야에서도 많이 사용된다. 

 

 

scikit-learn: machine learning in Python — scikit-learn 1.3.0 documentation

Model selection Comparing, validating and choosing parameters and models. Applications: Improved accuracy via parameter tuning Algorithms: grid search, cross validation, metrics, and more...

scikit-learn.org

 

오늘은 파이썬에서 필수적으로 사용되는 라이브러리 TOP6를 알아보았다. 각각의 라이브러리들이 제공하는 기능들이 매우 방대하기 때문에, 모든 기능들을 일일이 전부 익힐 필요는 없다. 그러나 어떤 작업을 수행할 때 어떤 라이브러리가 필요한 지 알아두는 것만으로도 데이터 분석가의 역할을 충분히 수행할 수 있다. 

반응형

댓글