始める無料で始める

バウンディングボックスへのアクセス

座標レベルの位置情報が付与されているツイートの多くは、バウンディングボックスという形式で提供されます。バウンディングボックスとは、ユーザーが位置している可能性のある特定の領域を示す、4組の経度・緯度座標のセットです。このバウンディングボックスは、Twitter の JSON の place 値の中に格納されています。

このデータセットは、tweets_sotu という DataFrame として読み込まれています。

この演習はコースの一部です

Python でのソーシャルメディアデータ分析

コースを見る

演習の手順

  • バウンディングボックスの辞書内の coordinates 値にアクセスして、getBoundingBox() 関数を完成させましょう。
  • tweets_sotu DataFrame の適切な列に getBoundingBox() 関数を適用しましょう。

実践的なインタラクティブ演習

このサンプルコードを完成させて、この演習に挑戦してみましょう。

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])
コードを編集して実行