본문 바로가기
개발일지/Pandas

pandas 틀린부분 복기 4

by 개발에정착하고싶다 2022. 7. 23.
320x100
# 문제 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.sort_values(by = 'weight', ascending=False).head(10)

# 결론적으로 답은 맞았지만 여기서 원하는 해답은
cars.nlargest(n = 10, columns= 'weight')
# 유용 1
# Call an appropriate method on the __cars__ DataFrame that provides plenty of __summary statistics__!

cars.describe()
# 유용2
# Create a correlation matrix for the cars DataFrame! Which factor has the highest negative correlation to mpg?

cars.corr()
300x250