경계 상자 접근하기
좌표 수준의 지리 정보를 포함한 대부분의 트윗은 보통 경계 상자 형태로 제공됩니다. 경계 상자는 사용자가 위치할 수 있는 특정 영역을 나타내는 네 개의 경도/위도 좌표 집합입니다. 이 경계 상자는 Twitter JSON의 place 값에 포함되어 있습니다.
데이터셋은 tweets_sotu라는 DataFrame으로 미리 로드되어 있습니다.
이 연습은 강의의 일부입니다
Python으로 소셜 미디어 데이터 분석하기
연습 안내
- 경계 상자 딕셔너리 내부에서 coordinates 값을 가져오도록
getBoundingBox()함수를 완성하세요. getBoundingBox()함수를tweets_sotuDataFrame의 해당 열에 적용하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
def getBoundingBox(place):
""" Returns the bounding box coordinates."""
return place[____][____]
# Apply the function which gets bounding box coordinates
bounding_boxes = tweets_sotu[____].apply(getBoundingBox)
# Print out the first bounding box coordinates
print(bounding_boxes.values[0])