<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Leul Dereje Bonsa</title>
    <description>The latest articles on DEV Community by Leul Dereje Bonsa (@leul12).</description>
    <link>https://dev.to/leul12</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1059352%2F7a16a7cf-b6c6-49d7-b945-8fe670fa7f1c.jpeg</url>
      <title>DEV Community: Leul Dereje Bonsa</title>
      <link>https://dev.to/leul12</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/leul12"/>
    <language>en</language>
    <item>
      <title>Geo coding Country Names in Python</title>
      <dc:creator>Leul Dereje Bonsa</dc:creator>
      <pubDate>Thu, 06 Apr 2023 09:43:29 +0000</pubDate>
      <link>https://dev.to/leul12/geo-coding-country-names-in-python-12ef</link>
      <guid>https://dev.to/leul12/geo-coding-country-names-in-python-12ef</guid>
      <description>

&lt;p&gt;Have you ever needed to work with Geo spatial data in your data analysis or mapping projects, but found yourself struggling to convert country names into geographic coordinates? That's exactly the challenge I faced recently while working on a project for a client. I needed to plot a map of their global operations, but all I had was a list of country names.After some research, I discovered that Python offers powerful tools for GEo-codding country names and obtaining their corresponding latitude and longitude coordinates. With the help of the &lt;a href="https://github.com/geopy/geopy"&gt;geopy&lt;/a&gt; and &lt;a href="https://pypi.org/project/pycountry/"&gt;pycountry&lt;/a&gt; libraries, I was able to quickly and easily convert the country names into coordinates, and plot them on a map using a mapping library like &lt;a href="https://python-visualization.github.io/folium/"&gt;folium&lt;/a&gt; and &lt;a href="https://plotly.com/"&gt;plotly&lt;/a&gt;.&lt;br&gt;
&lt;strong&gt;Geo-coding&lt;/strong&gt; is the process of converting a human-readable address or location name into geographic coordinates (latitude and longitude) that can be used in maps and other Geo-spatial applications.&lt;br&gt;
To get started, first make sure you have both &lt;a href="https://github.com/geopy/geopy"&gt;geopy&lt;/a&gt; and &lt;a href="https://pypi.org/project/pycountry/"&gt;pycountry&lt;/a&gt; installed in your Python environment. You can install them using pip by running &lt;code&gt;pip install geopy pycountry&lt;/code&gt; in your terminal or command prompt.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Next&lt;/strong&gt;, create a function that takes a country name as input and returns its latitude and longitude coordinates. Here's an example function that uses the Nominatim geocoder from geopy to look up the country's coordinates:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from geopy.geocoders import Nominatim
import pycountry

def get_coordinates(country):
    try:
        country_obj = pycountry.countries.get(name=country)
        geolocator = Nominatim(user_agent="my-application")
        location = geolocator.geocode(country_obj.name)
        return location.latitude, location.longitude
    except AttributeError:
        return None, None

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this function, we first use &lt;code&gt;pycountry&lt;/code&gt;to look up the &lt;code&gt;Country&lt;/code&gt;object for the given country name. We then create a new instance of the &lt;code&gt;Nominatim&lt;/code&gt;geocoder from &lt;code&gt;geopy&lt;/code&gt;, passing in a custom user agent string. Finally, we use the &lt;code&gt;geocode&lt;/code&gt;method of the geocoder to look up the coordinates for the country, and return them as a tuple.&lt;/p&gt;

&lt;p&gt;Note that in the &lt;code&gt;geocode&lt;/code&gt;method, we pass in &lt;code&gt;country_obj.name&lt;/code&gt; instead of just &lt;code&gt;country&lt;/code&gt;. This is because &lt;code&gt;Nominatim&lt;/code&gt;requires the input to be in the format of "City, State, Country" or "Street, City, State, Country". By passing in the country name as the only argument, we're more likely to get accurate results for countries with common or ambiguous names.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;To use this function on a pandas DataFrame, you can use the apply method as follows:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pandas as pd

df = pd.DataFrame({'country': ['United States', 'France', 'China']})
df[['latitude', 'longitude']] = df['country'].apply(get_coordinates).apply(pd.Series)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this code, we first create a new pandas Data Frame with a column named "country". We then use the apply method to &lt;code&gt;apply&lt;/code&gt;the &lt;code&gt;get_coordinates&lt;/code&gt;function to each value in the "country" column. Finally, we use the &lt;code&gt;apply&lt;/code&gt;method again, this time with &lt;code&gt;pd.Series&lt;/code&gt;as the argument, to split the resulting tuples of latitude and longitude into separate columns.&lt;/p&gt;

&lt;p&gt;If you need to handle special cases such as "World" or "International", you can modify the &lt;code&gt;get_coordinates&lt;/code&gt;function accordingly. For example, you can assign the coordinates of the Antarctic for "World", and the coordinates of the United Nations Headquarters in New York for "International".&lt;/p&gt;

&lt;h2&gt;
  
  
  That's it! With these tools and techniques, you should be able to geocode country names and work with geospatial data in Python.
&lt;/h2&gt;

</description>
      <category>geocoding</category>
      <category>python</category>
      <category>geospatial</category>
      <category>dataanalysis</category>
    </item>
    <item>
      <title>Overcoming the Odds:</title>
      <dc:creator>Leul Dereje Bonsa</dc:creator>
      <pubDate>Wed, 05 Apr 2023 11:28:21 +0000</pubDate>
      <link>https://dev.to/leul12/overcoming-the-odds-3leb</link>
      <guid>https://dev.to/leul12/overcoming-the-odds-3leb</guid>
      <description>&lt;h2&gt;
  
  
  The Inspiring Journey of Average Africans Pursuing Data Science Expertise
&lt;/h2&gt;

&lt;p&gt;Are you an average African with a burning passion for data science? Do you dream of becoming a data science expert but feel like the odds are stacked against you? Well, you're not alone. The journey to becoming a data science expert is no easy feat, especially for those in Africa who face unique challenges.&lt;/p&gt;

&lt;p&gt;From limited access to resources to language barriers, aspiring data scientists in Africa have to navigate a myriad of obstacles. But the good news is that despite these challenges, there are several solutions that can help you overcome them and achieve your dreams.&lt;/p&gt;

&lt;p&gt;Online learning platforms like Coursera, Udacity, and edX offer a wide range of data science courses that are accessible to anyone with an internet connection. These platforms allow you to learn at your own pace and acquire the skills you need to succeed in the field.&lt;/p&gt;

&lt;p&gt;Virtual mentoring programs can connect you with experienced professionals in the field who can provide guidance and support throughout your learning journey. These programs can help bridge the gap between the lack of mentors and role models in the field.&lt;/p&gt;

&lt;p&gt;Localization of data science resources can also make a significant difference. Translating existing resources into local languages or creating new resources that are specific to the needs of the African market can help make data science more accessible to those who do not speak English as their primary language.&lt;/p&gt;

&lt;p&gt;And let's not forget entrepreneurship and freelancing. With limited job opportunities for data science professionals in Africa, aspiring data scientists can leverage their skills to start their own businesses or work as freelancers. This can help create job opportunities for themselves and others while also contributing to the growth of the African economy.&lt;/p&gt;

&lt;p&gt;The journey to becoming a data science expert in Africa may be challenging, but it is not impossible. With determination, the right resources, and support, you can overcome the odds and make your dreams a reality. So, are you ready to take on the challenge and make a difference in your community and the world? The power is in your hands!&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>africa</category>
      <category>onlinelearning</category>
      <category>freelancing</category>
    </item>
  </channel>
</rss>
