In this tutorial. I will demonstrate how to use the Google Translate API for translating the data from Hindi to English.
Published in · 4 min read · Feb 22, 2020
--
There are some things I want to clear at the beginning of the tutorial. First, I would translate the data from Hindi to English. Also, I will demonstrate the translation on a Pandas Data Frame, meaning I will convert the entire data frame from Hindi to English. Isn’t that great? Well, let’s get started. Also, you can use the Google Colab notebook to type the code. I would recommend everyone go through the documentation of the Google Translate API for Python completely, so by the time you start to code you would probably know what I mean. It would be a cakewalk because you would know most of the terms while coding.
Open your Google Colab and create a new notebook and name it as “Google _Translations.ipynb”. Before actually typing the code I want all of you guys manually install the Google Translate library inside the notebook. So to do this just type !pip install googletrans
. This command automatically downloads and installs the library as shown below:
# install googletrans using pip
!pip install googletrans
Importing the necessary libraries
In this step, we will be importing the necessary libraries that we will be using throughout the tutorial. The library pandas are for storing the CSV data into a data frame. And googletrans is obviously used for translation and we will also use one of its methods called Translator which you will see in the later tutorial.
# Importing the necessary librariesimport pandas as pd
import googletrans
from googletrans import Translator