{
  "id": 199694,
  "title": "States in Cities Dataset",
  "url": "/competitions/cdp-unlocking-climate-solutions/discussion/199694",
  "author_name": "",
  "post_date": "2020-11-26T20:52:36.375118600Z",
  "votes": 2,
  "comment_count": 4,
  "views": 0,
  "content": "<p>Hey guys! Has anyone come up with a clever way to add states to the cities dataset that is somewhat accurate? Definitely wish that would have been an extra column, never knew there was so many city names that were common across states haha</p>",
  "messages": [
    {
      "id": "1092466",
      "postDate": "11/26/2020 20:52:36",
      "content": "<p>Hey guys! Has anyone come up with a clever way to add states to the cities dataset that is somewhat accurate? Definitely wish that would have been an extra column, never knew there was so many city names that were common across states haha</p>",
      "rawMarkdown": "Hey guys! Has anyone come up with a clever way to add states to the cities dataset that is somewhat accurate? Definitely wish that would have been an extra column, never knew there was so many city names that were common across states haha",
      "votes": null
    },
    {
      "id": "1092791",
      "postDate": "11/27/2020 07:07:51",
      "content": "<p>Hi jenni4j,<br>\n         I think we can get city, state, location using the latitude, longitude points . The column in cities dataset \"City Location\" has the points. This column is not null column.</p>\n<p>`from geopy.geocoders import Nominatim<br>\ngeolocator = Nominatim(user_agent=\"geoapiExercises\")<br>\ndef city_state_country(coord):<br>\n    location = geolocator.reverse(coord, exactly_one=True)<br>\n    address = location.raw['address']<br>\n    city = address.get('city', '')<br>\n    state = address.get('state', '')<br>\n    country = address.get('country', '')<br>\n    return city, state, country<br>\nprint(city_state_country(\"44.4938, 11.3387\")) #Account number=36274 and point=(11.3387 44.4938)</p>\n<h1>('Bologna', 'Emilia-Romagna', 'Italia')`</h1>\n<p>Thanks for the question and I hope this helps .kindly let me know if any other methods are available</p>",
      "rawMarkdown": "Hi jenni4j,\n         I think we can get city, state, location using the latitude, longitude points . The column in cities dataset \"City Location\" has the points. This column is not null column.\n\n`from geopy.geocoders import Nominatim\ngeolocator = Nominatim(user_agent=\"geoapiExercises\")\ndef city_state_country(coord):\n    location = geolocator.reverse(coord, exactly_one=True)\n    address = location.raw['address']\n    city = address.get('city', '')\n    state = address.get('state', '')\n    country = address.get('country', '')\n    return city, state, country\nprint(city_state_country(\"44.4938, 11.3387\")) #Account number=36274 and point=(11.3387 44.4938)\n#('Bologna', 'Emilia-Romagna', 'Italia')`\n\nThanks for the question and I hope this helps .kindly let me know if any other methods are available",
      "votes": null
    },
    {
      "id": "1092798",
      "postDate": "11/27/2020 07:16:23",
      "content": "<p><a href=\"https://www.kaggle.com/jenjordache\" target=\"_blank\">@jenjordache</a> also take a look at the ‘Locations of Corporations’ folder in the competitions ‘Supplementary Data’ folder for help with some US cities </p>",
      "rawMarkdown": "jenjordache also take a look at the ‘Locations of Corporations’ folder in the competitions ‘Supplementary Data’ folder for help with some US cities",
      "votes": null
    },
    {
      "id": "1096975",
      "postDate": "11/30/2020 22:58:08",
      "content": "<p>Thanks so much kavi! I ended up taking your approach and using the lat and longitude points - really helpful!</p>",
      "rawMarkdown": "Thanks so much kavi! I ended up taking your approach and using the lat and longitude points - really helpful!",
      "votes": null
    },
    {
      "id": "1097512",
      "postDate": "12/01/2020 04:43:36",
      "content": "<p>You are welcome, glad it helped 👍😃</p>",
      "rawMarkdown": "You are welcome, glad it helped 👍😃",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1092791,
      "author_name": "kavisekar",
      "author_url": "",
      "post_date": "11/27/2020 07:07:51",
      "content": "<p>Hi jenni4j,<br>\n         I think we can get city, state, location using the latitude, longitude points . The column in cities dataset \"City Location\" has the points. This column is not null column.</p>\n<p>`from geopy.geocoders import Nominatim<br>\ngeolocator = Nominatim(user_agent=\"geoapiExercises\")<br>\ndef city_state_country(coord):<br>\n    location = geolocator.reverse(coord, exactly_one=True)<br>\n    address = location.raw['address']<br>\n    city = address.get('city', '')<br>\n    state = address.get('state', '')<br>\n    country = address.get('country', '')<br>\n    return city, state, country<br>\nprint(city_state_country(\"44.4938, 11.3387\")) #Account number=36274 and point=(11.3387 44.4938)</p>\n<h1>('Bologna', 'Emilia-Romagna', 'Italia')`</h1>\n<p>Thanks for the question and I hope this helps .kindly let me know if any other methods are available</p>",
      "votes": null,
      "replies": [
        {
          "id": 1096975,
          "author_name": "jenjordache",
          "author_url": "",
          "post_date": "11/30/2020 22:58:08",
          "content": "<p>Thanks so much kavi! I ended up taking your approach and using the lat and longitude points - really helpful!</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1097512,
          "author_name": "kavisekar",
          "author_url": "",
          "post_date": "12/01/2020 04:43:36",
          "content": "<p>You are welcome, glad it helped 👍😃</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1092798,
      "author_name": "callumr22",
      "author_url": "",
      "post_date": "11/27/2020 07:16:23",
      "content": "<p><a href=\"https://www.kaggle.com/jenjordache\" target=\"_blank\">@jenjordache</a> also take a look at the ‘Locations of Corporations’ folder in the competitions ‘Supplementary Data’ folder for help with some US cities </p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1092466": "Hey guys! Has anyone come up with a clever way to add states to the cities dataset that is somewhat accurate? Definitely wish that would have been an extra column, never knew there was so many city names that were common across states haha",
    "1092791": "Hi jenni4j,\n         I think we can get city, state, location using the latitude, longitude points . The column in cities dataset \"City Location\" has the points. This column is not null column.\n\n`from geopy.geocoders import Nominatim\ngeolocator = Nominatim(user_agent=\"geoapiExercises\")\ndef city_state_country(coord):\n    location = geolocator.reverse(coord, exactly_one=True)\n    address = location.raw['address']\n    city = address.get('city', '')\n    state = address.get('state', '')\n    country = address.get('country', '')\n    return city, state, country\nprint(city_state_country(\"44.4938, 11.3387\")) #Account number=36274 and point=(11.3387 44.4938)\n#('Bologna', 'Emilia-Romagna', 'Italia')`\n\nThanks for the question and I hope this helps .kindly let me know if any other methods are available",
    "1092798": "jenjordache also take a look at the ‘Locations of Corporations’ folder in the competitions ‘Supplementary Data’ folder for help with some US cities",
    "1096975": "Thanks so much kavi! I ended up taking your approach and using the lat and longitude points - really helpful!",
    "1097512": "You are welcome, glad it helped 👍😃"
  },
  "source": "meta"
}