본문 바로가기

개발일지/Pandas50

pandas 판다스 rank, unique, nunique, count, 평균, 표준편차(mean, std), 상관계수 corr ## Sorting DataFrame (Version 1.0 Updte) import pandas as pd titanic = pd.read_csv('titanic.csv') titanic.age.sort_values() ''' 803 0.42 755 0.67 644 0.75 469 0.75 78 0.83 ... 859 NaN 863 NaN 868 NaN 878 NaN 888 NaN Name: age, Length: 891, dtype: float64 ''' titanic.sort_values(by = 'age') ''' survivedpclasssexagesibspparchfareembarkeddeck 80313male0.42018.5167CNaN 75512male0.671114.5000SNaN 644.. 2022. 7. 23.
pandas 판다스 틀린부분 복기3 이번 문제 자체는 짧았지만, 정말 중요한 부분이였다. 하지만 머리에 잘 남지 않아서 아쉬움이 남은 파트였다. 더 익숙해져 보도록 하자. # run the cell! import pandas as pd cars = pd.read_csv("cars.csv") cars ''' mpgcylindersdisplacementhorsepowerweightaccelerationmodel_yearoriginname 018.08307.0130.0350412.070usachevrolet chevelle malibu 115.08350.0165.0369311.570usabuick skylark 320 218.08318.0150.0343611.070usaplymouth satellite 316.08304.0150.0343312... 2022. 7. 19.
pandas 판다스 기초 11 체인인덱싱(chain indexing) 피하기, copy, 올바른 값 변경해주기 # Manipulating Values in DataFrame ## Best Practise (how you should do it) import pandas as pd titanic = pd.read_csv('titanic.csv') titanic.head() ''' survivedpclasssexagesibspparchfareembarkeddeck 003male22.0107.2500SNaN 111female38.01071.2833CC 213female26.0007.9250SNaN 311female35.01053.1000SC 403male35.0008.0500SNaN ''' ### Changing a single Value (Option 1 with loc) # inplace = True 필요없음 ti.. 2022. 7. 19.
pandas 판다스 틀린부분 복기2 # 문제 1 # Filter the DataFrame cars for all cars with an mpg between 10 and 15 (both ends inclusive!). # Save the subset in the variable mpg_10_15! Fill in the gaps! # between을 활용해야하는데, 기억이 잘 안나더라. 풀기야 했는데 복기용으로 남겨두자. mpg_10_15 = cars.loc[cars.mpg.between(10,15, inclusive=True)].copy() # 문제 2 # Filter the Dataframe cars for all cars that are not built in the years 73 and 74, and only the columns .. 2022. 7. 18.