Found 10805 Articles for Python

Analysing Mobile Data Speeds from TRAI with Pandas in Python

Hafeezul Kareem
Updated on 08-Jul-2020 07:29:29

71 Views

In this tutorial, we are going to analyze the mobile data speeds using the pandas package. Download the mobile speeds from the TRAI official website. Steps to download the file.Algorithm1. Go to the [TRAI](https://myspeed.trai.gov.in/ ) website. 2. Scroll down to the end of the page. 3. You will find mobile speed data for different months. 4. Download the September mobile data speeds.Let's see the columns in the CSV file.Network NameNetwork TechnologyType Of TestSpeedSignal StrengthStateWe need pandas, numpy, matplotlib libraries. Let's start the coding to analyze the data.Example# importing requires libraries import pandas as pd import numpy as np import matplotlib.pyplot ... Read More

Apply function to every row in a Pandas DataFrame in Python

Hafeezul Kareem
Updated on 01-Nov-2019 09:50:20

973 Views

In this tutorial, we are going to learn about the most common methods of a list i.e.., append() and extend(). Let's see them one by one.apply()It is used to apply a function to every row of a DataFrame. For example, if we want to multiply all the numbers from each and add it as a new column, then apply() method is beneficial. Let's see different ways to achieve it.Example# importing the pandas package import pandas as pd # function to multiply def multiply(x, y):    return x * y # creating a dictionary for DataFrame data = {    'Maths': ... Read More

Apply uppercase to a column in Pandas dataframe in Python

Hafeezul Kareem
Updated on 01-Nov-2019 09:47:01

1K+ Views

In this tutorial, we are going to see how to make a column of names to uppercase in DataFrame. Let's see different ways to achieve our goal.ExampleWe can assign a column to the DataFrame by making it uppercase using the upper() method.Let's see the code.# importing the pandas package import pandas as pd # data for DataFrame data = {    'Name': ['Hafeez', 'Aslan', 'Kareem'],    'Age': [19, 21, 18],    'Profession': ['Developer', 'Engineer', 'Artist'] } # creating DataFrame data_frame = pd.DataFrame(data) # displaying the DataFrame print('---------------------Before-------------------') print(data_frame) print() # making the Name column strings to upper case data_frame['Name'] = ... Read More

Arithmetic Operations on Images using OpenCV in Python

Hafeezul Kareem
Updated on 01-Nov-2019 09:45:00

561 Views

In this tutorial, we are going to learn about the arithmetic operations on Images using OpenCV. We can apply operations like addition, subtraction, Bitwise Operations, etc.., Let's see how we can perform operations on images.We need the OpenCV module to perform operations on images. Install the OpenCV module using the following command in the terminal or command line.pip install opencv-python==4.1.1.26If you run the above command, you will get the following successful message.Collecting opencv-python==4.1.1.26 Downloading https://files.pythonhosted.org/packages/1f/51/e0b9cef23098bc31c77b0e0 6221dd8d05119b9782d4c2b1d1482e22b5f5e/opencv_python-4.1.1.26-cp37-cp37m-win_amd64.w hl (39.0MB) Requirement already satisfied: numpy>=1.14.5 in c:\users\hafeezulkareem\anaconda3\l ib\site-packages (from opencv-python==4.1.1.26) (1.16.2) Installing collected packages: opencv-python Successfully installed opencv-python-4.1.1.26AdditionWe can add two images using ... Read More

as_integer_ratio() in Python for reduced fraction of a given rational

Hafeezul Kareem
Updated on 01-Nov-2019 09:42:09

242 Views

In this tutorial, we are going to write a program that returns two numbers whose ratio is equal to the given float value. We have a method called as_integer_ratio() that helps to achieve our goal.Let's see some examples.Input: 1.5 Output: 3 / 2 Input: 5.3 Output: 5967269506265907 / 1125899906842624Let's examine the code.Example# initializing the float value float_value = 1.5 # getting integers tuple using the as_integer_ratio() method integers = float_value.as_integer_ratio() # printing the integers print(f'{integers[0]} / {integers[1]}')OutputIf you run the above code, you will get the following results.3 / 2 Let's see another example.Example# initializing the float value float_value = ... Read More

Arithmetic operations using OpenCV in Python

Hafeezul Kareem
Updated on 01-Nov-2019 09:40:12

166 Views

In this tutorial, we are going to perform arithmetic operations on images using OpenCV in Python. We need to install the OpenCV module.Run the following command to install the OpenCV module.pip install opencv-python==4.1.1.26If you run the above command, you will get the following successful message.Collecting opencv-python==4.1.1.26 Downloading https://files.pythonhosted.org/packages/1f/51/e0b9cef23098bc31c77b0e0 6221dd8d05119b9782d4c2b1d1482e22b5f5e/opencv_python-4.1.1.26-cp37-cp37m-win_amd64.w hl (39.0MB) Requirement already satisfied: numpy>=1.14.5 in c:\users\hafeezulkareem\anaconda3\l ib\site-packages (from opencv-python==4.1.1.26) (1.16.2) Installing collected packages: opencv-python Successfully installed opencv-python-4.1.1.26Adding Two ImagesWe need two images for the addition. We have a method called cv2.add(image_one, image_two) to perform addition. It's very hand method. The sizes of the two images must be the same. ... Read More

Audio processing using Pydub and Google Speech Recognition API in Python

Hafeezul Kareem
Updated on 01-Nov-2019 08:19:42

639 Views

In this tutorial, we are going to work with the audio files. We will breakdown the audio into chunks to recognize the content in it. We will store the content of the audio files in text files as well. Install the following modules using the below commands.pip install pydubIf you run the above command, you will get the following successful messageCollecting pydub Downloading https://files.pythonhosted.org/packages/79/db/eaf620b73a1eec3c8c6f8f5 b0b236a50f9da88ad57802154b7ba7664d0b8/pydub-0.23.1-py2.py3-none-any.whl Installing collected packages: pydub Successfully installed pydub-0.23.1pip install audioreadIf you run the above command, you will get the following successful message.Collecting audioread Downloading https://files.pythonhosted.org/packages/2e/0b/940ea7861e0e9049f09dcfd 72a90c9ae55f697c17c299a323f0148f913d2/audioread-2.1.8.tar.gz Building wheels for collected packages: audioread Building wheel for audioread ... Read More

Barnsley Fern in Python

Hafeezul Kareem
Updated on 01-Nov-2019 08:11:37

282 Views

In this tutorial, we are going to learn about the Barnsley Fern, which is created by Michael Barnsley. The features of Barnsley Fern is similar to the fern shape. It is created by iterating over the four mathematical equations known as Iterated Function System(IFS). The transformation has the following formula.f(x, y)=$$\begin{bmatrix}a & b \c & d \end{bmatrix}\begin{bmatrix}x \y \end{bmatrix}+\begin{bmatrix}e \f \end{bmatrix}$$Source − WikipediaThe values of the variables are −Source − WikipediaThe four equation that Barnsley Fern proposed are −Source − WikipediaNow, we will see code to create the fern shape in Python.Example# importing matplotlib module for the plot import matplotlib.pyplot ... Read More

Basic Python Programming Challenges

Hafeezul Kareem
Updated on 01-Nov-2019 08:06:14

303 Views

In this tutorial, we are going to write a solution for a challenge.ChallengeWe have to generate a random set of basic arithmetic operations. The user will give the number of questions, and we have to generate questions. After every question, the user will answer it. At the end of the program, we have to give the score. Let's try it.Example# importing random and operator modules import random import operator # main function # taking number of questions that we have to generate def main(n):    print("Welcome to the quizYou should answer floats upto 2 decimals")    # initialising score to ... Read More

Beginner Tips for Learning Python

Vikram Chiluka
Updated on 12-Oct-2022 12:23:06

147 Views

Python is a computer programming language that is frequently used to create websites and software, automate tasks, and analyze data. Python is a general-purpose programming language, which means it can be used to create a wide range of programs and is not specialized for any particular problem. This versatility, combined with its ease of use for beginners, has made it one of the most widely used programming languages today It is regarded as the best language for beginners, to begin with. Nowadays, almost every company that has an application, a website, or any computer-driven hardware requires programming. Needless to say, ... Read More

Advertisements