Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Rohan Singh
Page 8 of 15
How to Replace Values in Columns Based on Condition in Pandas
In Python, we can replace values in columns based on conditions in Pandas using various built-in functions like loc, where and mask, apply and lambda, map, and numpy.where. Pandas is a powerful library for data manipulation and working with structured data. This article demonstrates five different methods to conditionally replace column values. Using loc The loc function allows you to access and modify specific rows and columns in a DataFrame based on boolean conditions ? Syntax df.loc[row_condition, column_labels] = new_value Example Let's replace the gender of people aged 50 or older with ...
Read MoreFaulty calculator using Python
A faulty calculator in Python is a calculator that gives incorrect results for certain calculations. In Python, we can create our own calculator and use it for doing mathematical calculations. If we want to create a faulty calculator we need to create or introduce errors in the functions that perform the calculations. In this article, we will create a faulty calculator using Python. Creating a Faulty Calculator Creating a faulty calculator is easy as we need to just introduce some incorrect calculations in the normal calculator in the code to give an incorrect result which converts it into ...
Read MoreHow to replace a word in Excel using Python?
In Python, we can replace a word in Excel with another word using a third-party Python library called openpyxl. Microsoft Excel is a useful tool that is used for managing and analyzing data. Using Python we can automate some of the Excel data management tasks. In this article, we will understand how we can replace a word in Excel using Python. Installing openpyxl Before implementing the program to replace words in Excel we need to install the openpyxl library in our system using the Python package manager. To install openpyxl type the following command on your terminal or ...
Read MoreFacts App Using Tkinter module
In Python, we can use the Tkinter module and randfacts module to create a Facts generator App. Tkinter is Python's built-in GUI toolkit that allows you to create graphical applications with buttons, labels, text boxes, and other widgets. The randfacts module generates random interesting facts. In this article, we will implement a Fact App Generator GUI application using Tkinter and the randfacts module. Installing Required Dependencies To create the facts generator app, we first need to install the randfacts module using pip. Type the following command in your terminal or command prompt ⤦ pip install randfacts ...
Read MoreFacts about Cython Programming Language
Cython is a programming language that is a superset of Python and can be compiled into C code for improved performance. Cython is developed to improve the execution speed and make the code faster compared to Python. In this article, we will look at some interesting facts about Cython Programming Language. Cython can be used to speed up Python code As the name suggests Cython is Python-like code that can be converted to C code for faster and improved execution speed. Developers can write code in Python which is then compiled into C code and makes the language ...
Read MoreExtracting locations from text using Python
In Python, we can extract locations from text using NLP libraries such as NLTK, spaCy, and TextBlob. Extracting locations from text is crucial for various Natural Language Processing tasks such as sentiment analysis, information retrieval, and social media analysis. In this article, we will discuss how to extract locations from text using the spaCy library. Prerequisites Installing spaCy Library Before using the spaCy library for location extraction, you need to install it using the pip command. Type the following command in your terminal or command prompt ? pip install spacy Download the Pre-trained ...
Read MoreExtracting an attribute value with beautiful soup in Python
To extract an attribute value with the help of Beautiful Soup we need to parse the HTML document and then extract the required attribute value. Beautiful Soup is a Python library that is used to parse HTML and XML documents. BeautifulSoup provides several methods to search and navigate the parse tree, making it easy to extract data from the documents. In this article, we will extract attribute values with the help of Beautiful Soup in Python. Algorithm You can follow the below-given algorithm to extract attribute values with beautiful soup in Python: Parse ...
Read MoreExtract the title from a webpage using Python
In Python, we can extract the title from a webpage using web scraping. Web scraping is the process of extracting data from a website or webpage. In this article, we will scrape the title of a webpage using various Python libraries including Requests, BeautifulSoup, urllib, Selenium, and regular expressions. Method 1: Using Requests and BeautifulSoup The most common approach uses the requests library to send HTTP requests and BeautifulSoup to parse HTML content. The requests library fetches the webpage, and BeautifulSoup extracts the title tag. Example In the below example, we extract the title of the ...
Read MoreDraw a circle using Arcade in Python3
Arcade is a Python library used to create 2D games and applications. It provides easy-to-use functionality for drawing shapes and images on the screen. In this article, we will learn how to draw circles using Arcade in Python3. Installing Arcade Before drawing circles, install the Arcade library using pip ? pip install arcade Method 1: Using arcade.draw_circle_filled() The most straightforward way to draw a circle is using the draw_circle_filled() method. Syntax arcade.draw_circle_filled(x, y, radius, color) Parameters x − The x-coordinate of the circle's center point y ...
Read Moredrag_and_drop_by_offset method – Action Chains in Selenium Python
The drag_and_drop_by_offset() method in Selenium's Action Chains allows you to drag an element to a new position using pixel coordinates. This method is particularly useful for interacting with sliders, draggable widgets, and custom UI elements. What is drag_and_drop_by_offset? The drag_and_drop_by_offset() method drags an element from its current position to a new location specified by x and y offset values. The method takes three parameters: the element to drag, x-offset (horizontal pixels), and y-offset (vertical pixels). Syntax drag_and_drop_by_offset(source, xoffset, yoffset) Parameters source − The element to drag xoffset − Horizontal distance in ...
Read More