Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- es6
- window
- 보조정렬
- tomcat
- GIT
- Eclipse
- hadoop
- Android
- JavaScript
- R
- Express
- Java
- Sqoop
- SQL
- table
- IntelliJ
- Spring
- mapreduce
- react
- mybatis
- vaadin
- Kotlin
- Python
- SPC
- 공정능력
- MSSQL
- SSL
- NPM
- plugin
- xPlatform
Archives
- Today
- Total
DBILITY
python pandas dataframe 본문
반응형
R의 dataframe을 사용해 봤는데, 기억이 나질 않는다.^^;
공식문서를 참조하자. https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html
pandas.DataFrame — pandas 1.3.3 documentation
Column labels to use for resulting frame when data does not have them, defaulting to RangeIndex(0, 1, 2, …, n). If data contains column labels, will perform column selection instead.
pandas.pydata.org
2차원의 변경 가능하고 칼럼 별로 다른 데이터 타입의 저장이 가능하다.
기본구조는 다음과 같다.
pandas.DataFrame(data=None, index=None, columns=None, dtype=None, copy=None)
- Dictionary로 생성
>>> import pandas as pd >>> dct = {'col1': [1, 2], 'col2': ['a', 'b']} >>> dct {'col1': [1, 2], 'col2': ['a', 'b']} >>> type(dct) <class 'dict'> >>> df = pd.DataFrame(data=dct) >>> df col1 col2 0 1 a 1 2 b >>> df.dtypes col1 int64 col2 object dtype: object
- Numpy ndarray로 생성
>>> ndarr = np.array([[1,2,3],[4,5,6],[7,8,9]]) >>> type(ndarr) <class 'numpy.ndarray'> >>> df2 = pd.DataFrame(data=ndarr,columns=['a','b','c']) >>> df2 a b c 0 1 2 3 1 4 5 6 2 7 8 9 >>> type(df2) >>> <class 'pandas.core.frame.DataFrame'> df2.dtypes a int32 b int32 c int32 dtype: object
나머지는 필요할 때 공식문서를 참고하자.
반응형
'python' 카테고리의 다른 글
python matplot scatter chart , linear regression line exercise (0) | 2021.10.13 |
---|---|
python papago translate api example (0) | 2021.10.12 |
python matplot pie chart (0) | 2021.08.30 |
python matplot bar chart example (0) | 2021.08.27 |
python matplot line chart example (0) | 2021.08.25 |
Comments