Algorithm/Python

[stratascratch] Bikes Last Used(Python)

yujin.me 2021. 8. 19. 01:22

문제

Find the last time each bike was in use. Output both the bike number and the date-timestamp of the bike's last use (i.e., the date-time the bike was returned). Order the results by bikes that were most recently used.

각 자전거가 마지막으로 사용된 시간 찾기. 
자전거 번호와 자전거의 마지막 사용 날짜(자전거가 반환된 날짜) 조회
가장 최근에 사용한 순서로 정렬

코드

# Import your libraries
import pandas as pd

# Start writing code
dc_bikeshare_q1_2012.head()
dc_bikeshare_q1_2012.groupby(['bike_number'])['end_time'].max().sort_values(ascending=False).reset_index()

출처

반응형