판다스로 파일 불러오기

파일 이름 조심하고 정확한 경로 설정 후 파일 불러오기

import pandas as pd

data_frame = pd.read_csv('C:/Users/Neverland/Desktop/SAI/test_csv_file.csv')

head : 위에서부터 몇개의 데이터를 불러올지

tail : 아래서부터 몇개의 데이터를 불러올지

ㄷdata_frame
ID LAST_NAME  AGE
0   1       KIM   30
1   2      CHOI   25
2   3       LEE   41
3   4      PARK   19
4   5       LIM   36

data_frame.head(2)
ID LAST_NAME  AGE
0   1       KIM   30
1   2      CHOI   25

data_frame.tail(2)
ID LAST_NAME  AGE
3   4      PARK   19
4   5       LIM   36

type(data_frame.ID)
<class 'pandas.core.series.Series'>

data_frame은 series의 결합체이다.

s1 = pd.core.series.Series([1,2,3])
s2 = pd.core.series.Series(['one', 'two', 'three'])

pd.DataFrame(data = dict(num=s1, word=s2))
   num   word
0    1    one
1    2    two
2    3  three