분류 전체보기718 pandas 판다스 기초 12 Matplotlib 이번 파트는 정말정말 중요한 부분중에 하나라고 본다. # The plot() method import pandas as pd titanic = pd.read_csv('titanic.csv') titanic.info() ''' RangeIndex: 891 entries, 0 to 890 Data columns (total 9 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 survived 891 non-null int64 1 pclass 891 non-null int64 2 sex 891 non-null object 3 age 714 non-null float64 4 sibsp 891 non-null int64 5 parc.. 2022. 7. 26. pandas 틀린부분 복기 5 apply, value_counts # 문제1 # Calculate for all numerical columns the range between highest and lowest value! Fill in the gaps! The range for mpg is...? # apply 가 생각이 안났다. # 어차피 답안을 보니깐 틀린듯 하다. 왜 이런 결과가 나왔을까? # 차이가 너무 심하게 난다. # 행 전부에 열은 model_year까지 가져오는 것이고.. # axis가 행을 기준으로 해서 그런건가? # 행을 기준으로하면 확실히 최고값인 weight에서 최소값인 cylinders를 빼면 말이 된다. cars.iloc[:, :-2].apply(lambda x: x.max() - x.min(), axis = 1) cars.iloc[:,:-2.. 2022. 7. 25. pandas 판다스 기초11 slice, upper, lower, title등 Series의 경우에 작동하는 문법 # 원하는 결과값은 전체 출력이다. # 전체출력은 원래 그냥 변수만 입력해주면 끝나지만, # 다중 인덱스를 슬라이스해서 전체출력을 해주는 것이 유의미 할것같아서 시도해보고 싶었다. # 시도 1 # titanic.loc[(slice(all), slice(all)), :] # TypeError: ' 2022. 7. 25. pandas 틀린부분 복기 4 # 문제 1 # Sort the cars DataFrame by the index from low to high. Save the order! # index 기준으로 정렬 하는 법을 모르겠다. # cars.sort_values(by = index) # cars.sort_values(by = 'index') # cars.sort_values(by = 'index', axis=1) # cars.sort_values(by = row, axis=1) # 그냥 간단하게 sort_index였다... cars.sort_index(ascending= True, inplace=True) # 틀린건 아니지만 취지에는 틀렸던 것 1 #Select the 10 cars with the highest weights!\ cars.. 2022. 7. 23. 이전 1 ··· 100 101 102 103 104 105 106 ··· 180 다음