Python 데이터 분석의 pandas 읽 기 데이터
csv,tsv,txt 파일 읽 기
1)CSV 파일 읽 기:
문법 형식:pandas.readcsv(파일 경로)
CSV 파일 내용 은 다음 과 같 습 니 다.
import pandas as pd
file_path = "e:\\pandas_study\\test.csv"
content = pd.read_csv(file_path)
content.head() # 5
content.head(3) # 3
content.shape # ( , ),
content.index # , <class 'pandas.core.indexes.range.RangeIndex'>
content.column # Index([' ', ' ', ' '], dtype='object')
content.dtypes #
object
int64
object
dtype: object
2)CSV 파일 읽 기:문법 형식:pandas.readcsv(파일 경로)
CSV 파일 내용 은 다음 과 같 습 니 다.
import pandas as pd
file_path = "e:\\pandas_study\\test2.txt"
content = pd.read_csv(file_path,sep='\t',header = None ,names= ['name','age','adress'])
# :
# header = None
# sep='\t'
# names= ['name','age','adress'] , 'name','age','adress'
content.head() # 5
content.head(3) # 3
content.shape # ( , ),
content.index # , <class 'pandas.core.indexes.range.RangeIndex'>
content.column # Index([' ', ' ', ' '], dtype='object')
content.dtypes #
3.엑셀 파일 읽 기
import pandas as pd
file_path = "e:\\pandas_study\\test3.xlsx"
content = pd.read_excel(file_path)
content.head() # 5
content.head(3) # 3
content.shape # ( , ),
content.index # , <class 'pandas.core.indexes.range.RangeIndex'>
content.column # Index([' ', ' ', ' '], dtype='object')
content.dtypes #
object
int64
object
dtype: object
4.데이터베이스 표 읽 기문법:pandas.readsql(sql 구문,데이터베이스 연결 대상)
데이터 대상 생 성,pymysql,cxOacle 등 모듈 은 my sql 이나 Oacle 을 연결 합 니 다.
파 이 썬 데이터 분석 에 관 한 pandas 읽 기 데이터 에 관 한 이 글 은 여기까지 소개 되 었 습 니 다.더 많은 관련 pandas 읽 기 데이터 내용 은 우리 의 이전 글 을 검색 하거나 아래 의 관련 글 을 계속 찾 아 보 세 요.앞으로 많은 지원 바 랍 니 다!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
로마 숫자를 정수로 또는 그 반대로 변환그 중 하나는 로마 숫자를 정수로 변환하는 함수를 만드는 것이었고 두 번째는 그 반대를 수행하는 함수를 만드는 것이었습니다. 문자만 포함합니다'I', 'V', 'X', 'L', 'C', 'D', 'M' ; 문자열이 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.