본문 바로가기

101

How do I change the data type of a pandas Series? Source: youtu.be/V0AWyzVMf54 2020. 11. 26.
How do I use string methods in pandas? Source: youtu.be/bofaC0IckHo 2020. 11. 26.
How do I use the "axis" parameter in pandas? Source: youtu.be/PtO3t6ynH-8 2020. 11. 26.
How do I apply multiple filter criteria to a pandas DataFrame? Source: youtu.be/YPItfQ87qjM 2020. 11. 26.
How do I filter rows of a pandas DataFrame by column value? Source: youtu.be/2AFGPdNn4FM 2020. 11. 26.
How do I sort a pandas DataFrame or a Series? Source: youtu.be/zY4doF6xSxY 2020. 11. 26.
How do I remove columns from a pandas DataFrame? Source: youtu.be/gnUKkS964WQ ufo = pd.read_csv('http://bit.ly/uforeports') ufo.head() #(row, column) 조회 ufo.shape #axis = 0 -> row axis, axis = 1 -> column axis ufo.drop('Colors Reported', axis=1, inplace=True) ufo.head() #2개 이상 제거할 경우 [] 이용 ufo.drop(['City', 'State'], axis = 1, inplace=Ture) ufo.head() #row 제거하는 법 ufo.drop([0, 1], axis=0, inplace=Ture) ufo.head() #row 제거 확인 완료 ufo.shape 2020. 11. 26.
How do I rename columns in a pandas DataFrame? Source: youtu.be/0uBirYFhizE ufo = pd.read_csv('http://bit.ly/uforeports') ufo.head() ufo.columns ufo.rename(columns = {'Colors Reported':'Colors_Reported', 'Shape Reported':'Shape_Reported'}, inplace=True) ufo.columns ufo_cols = ['city', 'colors reported', 'shape reported', 'state', 'time'] ufo.columns = ufo_cols ufo.head() #파일을 불러오면서 columns 이름 자체를 바꿈 ufo = pd.read_csv('http://bit.ly/uforeport.. 2020. 11. 26.
Why do some pandas commands end with parentheses, and others don't? Source: youtu.be/hSrDViyKWVk movies = pd.read_csv('http://bit.ly/imdbrathings') movies.head() #숫자로 표현된 Column들만 정리해서 보여줌 movies.describe() movie.dtypes type(movies) -> pandas.core.frame.DataFrame #object data 포함해서 확인하기 moives.describe(include=['object']) 괄호 안 아무곳 커서 클릭 후 'Shift + Tab' 누르면 함수 설명 조회 가능 2020. 11. 26.
How do I select a pandas Series from a DataFrame Source: youtu.be/zxqjeyKP2Tk ufo = pd.read_table('http://bit.ly/uforeports', sep=',') type(ufo) #pandas.core.frame.DataFrame 여부 확인 ufo.head() ufo['City'] #ufo.City로 입력해도 동일. ufo['City']보다 입력하기 편리하므로 ufo.City사용 ufo['Colors Reported'] #ufo.Color_Reported로 입력해서 출력되지 않으면, ['Colors Reported'] 방법 사용 #이미 입력되어 있는 Column들을 새로 만들어서 Column 추가 가능 ufo.City + ufo.State ufo.City + ', ' + ufo.State #New Column .. 2020. 11. 26.
How do I read a tabular data file into pandas? Source: youtu.be/5_QXMwezPJE import pandas as pd #pd.read_table('파일경로') pd.read_table('http://bit.ly/chiporders') orders = pd.read_table('http://bit.ly/chiporders') orders.head() pd.read_table('http://bit.ly/movieusers') # '|'로 구분되어 있으므로 Column을 나눠줌 pd.read_table('http://bit.ly/movieusers', sep='|') #1st row를 Header로 인식하므로 Header를 추가해줌 pd.read_table('http://bit.ly/movieusers', sep='|', header=No.. 2020. 11. 26.