[Python] help() 함수 사용법

2023. 10. 8. 20:27· Python

작성일자 : 2023-10-08

Ver 0.1.1

1. help()의 용도

파이썬은 굉장히 많은 Module(≒ Package)과 Function(함수), Class(클래스), Method(메서드)를 가지고 있다. 

굉장히 많은 기능 및 함수, 그리고 그 함수들의 옵션을 전부 외우고 있다면 좋겠지만, 그러기가 쉽지는 않다.

이에 사용법에 대해서는 공식 문서를 보거나 구글링을 하면 알 수 있다. 상황이 따라준다면 공식 문서나 구글링을 사용해도 좋지만,

인터넷이 되지 않는 환경이거나 다른 제한이 있는 경우 용도에 대해서 알 수 있는 방법이 있다.

 

특히, 빅분기 실기를 준비하면서 빅분기의 경우 검색 및 자동 완성 기능을 사용할 수 없기에 더더욱이 dir()함수와 help() 함수를 잘 활용해야 했다.

 

파이썬 IDE 내부에서 help() 함수를 사용하여 특정 Module의 Function, 또는 Instance에 사용할 수 있는 Method에 대한 자세한 도움말과 사용법을 조회할 수 있다. 

 

당연히 지원 언어는 영어이다 ^^


2, help()의 사용 방법 및 예시

(1) 파이썬의 Module A가 가진 funcnion a에 대한 도움말 출력

help(module A.function a)
import pandas as pd
help(pd.read_csv)

Help on function read_csv in module pandas.io.parsers.readers:

 

read_csv(filepath_or_buffer: 'FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str]', *, sep: 'str | None | lib.NoDefault' = <no_default>, delimiter: 'str | None | lib.NoDefault' = None, header: "int | Sequence[int] | None | Literal['infer']" = 'infer', names: 'Sequence[Hashable] | None | lib.NoDefault' = <no_default>, index_col: 'IndexLabel | Literal[False] | None' = None, usecols=None, dtype: 'DtypeArg | None' = None, engine: 'CSVEngine | None' = None, converters=None, true_values=None, false_values=None, skipinitialspace: 'bool' = False, skiprows=None, skipfooter: 'int' = 0, nrows: 'int | None' = None, na_values=None, keep_default_na: 'bool' = True, na_filter: 'bool' = True, verbose: 'bool' = False, skip_blank_lines: 'bool' = True, parse_dates: 'bool | Sequence[Hashable] | None' = None, infer_datetime_format: 'bool | lib.NoDefault' = <no_default>, keep_date_col: 'bool' = False, date_parser=<no_default>, date_format: 'str | None' = None, dayfirst: 'bool' = False, cache_dates: 'bool' = True, iterator: 'bool' = False, chunksize: 'int | None' = None, compression: 'CompressionOptions' = 'infer', thousands: 'str | None' = None, decimal: 'str' = '.', lineterminator: 'str | None' = None, quotechar: 'str' = '"', quoting: 'int' = 0, doublequote: 'bool' = True, escapechar: 'str | None' = None, comment: 'str | None' = None, encoding: 'str | None' = None, encoding_errors: 'str | None' = 'strict', dialect: 'str | csv.Dialect | None' = None, on_bad_lines: 'str' = 'error', delim_whitespace: 'bool' = False, low_memory=True, memory_map: 'bool' = False, float_precision: "Literal[('high', 'legacy')] | None" = None, storage_options: 'StorageOptions' = None, dtype_backend: 'DtypeBackend | lib.NoDefault' = <no_default>) -> 'DataFrame | TextFileReader'

    Read a comma-separated values (csv) file into DataFrame.

    

    Also supports optionally iterating or breaking of the file

    into chunks.

    

    Additional help can be found in the online docs for

    `IO Tools <https://pandas.pydata.org/pandas-docs/stable/user_guide/io.html>`_.

    

    Parameters

    ----------

    filepath_or_buffer : str, path object or file-like object

        Any valid string path is acceptable. The string could be a URL. Valid

        URL schemes include http, ftp, s3, gs, and file. For file URLs, a host is

        expected. A local file could be: file://localhost/path/to/table.csv.

    

        If you want to pass in a path object, pandas accepts any ``os.PathLike``.

    

        By file-like object, we refer to objects with a ``read()`` method, such as

        a file handle (e.g. via builtin ``open`` function) or ``StringIO``.

    sep : str, default ','

        Delimiter to use. If sep is None, the C engine cannot automatically detect

        the separator, but the Python parsing engine can, meaning the latter will

...

    Examples

    --------

    >>> pd.read_csv('data.csv')  # doctest: +SKIP

 

Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...

 

(2) 파이썬의 Instance B의 클래스가 사용 가능한 Method b의 도움말 출력

help(Instance B.Method b)
help(str.capitalize)

Help on method_descriptor:

 

capitalize(self, /)

    Return a capitalized version of the string.

    

    More specifically, make the first character have upper case and the rest lower

    case.

 

(3) 파이썬의 Module C가 가진 Class c에 대한 도움말 출력

help(Module C.Class c)
import pandas as pd
help(pd.DataFrame)

Help on class DataFrame in module pandas.core.frame:

 

class DataFrame(pandas.core.generic.NDFrame, pandas.core.arraylike.OpsMixin)

 |  DataFrame(data=None, index: 'Axes | None' = None, columns: 'Axes | None' = None, dtype: 'Dtype | None' = None, copy: 'bool | None' = None) -> 'None'

 |  

 |  Two-dimensional, size-mutable, potentially heterogeneous tabular data.

 |  

 |  Data structure also contains labeled axes (rows and columns).

 |  Arithmetic operations align on both row and column labels. Can be

 |  thought of as a dict-like container for Series objects. The primary

 |  pandas data structure.

 |  

 |  Parameters

 |  ----------

 |  data : ndarray (structured or homogeneous), Iterable, dict, or DataFrame

 |      Dict can contain Series, arrays, constants, dataclass or list-like objects. If

 |      data is a dict, column order follows insertion-order. If a dict contains Series

 |      which have an index defined, it is aligned by its index. This alignment also

 |      occurs if data is a Series or a DataFrame itself. Alignment is done on

 |      Series/DataFrame inputs.

 |  

 |      If data is a list of dicts, column order follows insertion-order.

 |  

 |  index : Index or array-like

 |      Index to use for resulting frame. Will default to RangeIndex if

...

 |  Data and other attributes inherited from pandas.core.arraylike.OpsMixin:

 |  

 |  __hash__ = None

 

Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...

저작자표시 (새창열림)
'Python' 카테고리의 다른 글
  • [Python] 모듈(module) 사용하기
  • [Python] lambda 함수
  • [Python]Numpy
  • [Python]Basic(1)
Unlimited Jun
Unlimited Jun
This space is my database for experiencing, thinking, studying, reading and working results
Unlimited Jun
JUST DO IT
Unlimited Jun
전체
오늘
어제

◀ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ   May   ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ▶
일 월 화 수 목 금 토
1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
  • 분류 전체보기 (324)
    • JayJay (32)
      • Thoughts (20)
      • Experiences (9)
    • Books (20)
    • Project (6)
    • Side Project (18)
      • Football Analysis (15)
      • Game Analysis (1)
      • TQRDC (2)
    • Tableau (28)
      • Dashboards (8)
      • Desktop (8)
      • Cloud&Server (5)
    • SQL (53)
      • DDL (6)
      • DML - SELECT (10)
      • DML (4)
      • DCL (1)
      • Optimization (7)
      • Oracle (18)
      • MySQL (2)
      • Coding Test (0)
    • Python (68)
      • numpy (0)
      • pandas (16)
      • plotly (6)
      • matplotlib (19)
      • seaborn (4)
      • altair (6)
      • streamlit (1)
      • scipy (5)
    • R (9)
    • Salesforce (7)
      • SOQL (4)
    • Excel (4)
    • HTML (3)
    • Markdown (1)
    • IT 일반 (13)
    • Tool (33)
      • Data Analysis Tool (26)
    • Data Analysis (28)
      • Data & Statistics (6)
      • 빅 데이터 분석기사 (22)
    • Etc (1)

태그

  • pandas
  • 데이터분석
  • SQL
  • 파이썬
  • oracle
  • 축구
  • 데이터시각화
  • Tableau
  • 시각화
  • Python

인기 글

최근 댓글

블로그 메뉴

  • 홈
  • 태그
  • 방명록
  • 글쓰기
  • LinkedIn
  • Tableau Public
  • 블로그 관리
hELLO · Designed By 정상우.v4.2.1
Unlimited Jun
[Python] help() 함수 사용법
상단으로

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.