문제
Number Of Bathrooms And Bedrooms
Find the average number of bathrooms and bedrooms for each city’s property types. Output the result along with the city name and the property type.
각각의 city와 property_type별로 bedrooms와 bathrooms의 평균 구하기
코드
airbnb_search_details.groupby(['city','property_type'])[['bedrooms','bathrooms']].mean()
인덱스에 있는 값을 컬럼으로 빼주기 위해서 reset_index() 사용
# Import your libraries
import pandas as pd
# Start writing code
airbnb_search_details.head()
add = airbnb_search_details.groupby(['city','property_type'])[['bedrooms','bathrooms']].mean()
add.reset_index()
출처
반응형
'Algorithm > Python' 카테고리의 다른 글
[stratascratch] Largest Olympics(Python) (0) | 2021.08.15 |
---|---|
[stratascratch] find the top 10 ranked songs in 2010(Python) (0) | 2021.08.15 |
[stratascratch] Count the number of movies that Abigail Breslin nominated for oscar(Python) (0) | 2021.08.07 |
[프로그래머스] 모의고사 (Python) (0) | 2021.07.22 |
[백준알고리즘] 1934번 최소공배수 (Python) (0) | 2021.07.13 |