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 Atharva Shah
Page 5 of 6
HandCalcs Module Python
HandCalcs is a Python library that automatically generates LaTeX-formatted mathematical equations from Python calculations. It creates beautiful, hand-written-style mathematical documentation directly from your Python code, making it essential for technical reports and scientific documentation. Installation Install HandCalcs using pip ? pip install handcalcs Basic Usage HandCalcs works primarily in Jupyter notebooks using the %%render magic command. Import the library and use the decorator to render calculations ? import handcalcs.render Example 1: Basic Arithmetic This example demonstrates simple numerical calculations with automatic LaTeX rendering ? %%render a ...
Read MoreFull outer join in PySpark dataframe
A Full Outer Join is an operation that combines the results of a left outer join and a right outer join. In PySpark, it is used to join two dataframes based on a specific condition where all the records from both dataframes are included in the output regardless of whether there is a match or not. This article will provide a detailed explanation of how to perform a full outer join in PySpark and provide a practical example to illustrate its implementation. Installation and Setup Before we can perform a full outer join in PySpark, we need to ...
Read MoreFormatting containers using format() in Python
The format() method in Python provides powerful ways to control how containers like lists, tuples, dictionaries, and sets are displayed. This method allows you to customize alignment, padding, precision, and presentation of your data structures for better readability. Formatting Lists You can format lists by joining elements with custom separators using format() ? my_list = [1, 2, 3, 4, 5] formatted_list = ', '.join(['{}'.format(x) for x in my_list]) print(formatted_list) 1, 2, 3, 4, 5 The join() method combines the formatted numbers with a comma and space separator. Each integer value replaces ...
Read MoreEmulating Numeric Types in Python
Python includes built-in mathematical data structures like complex numbers, floating-point numbers, and integers. But occasionally we might want to develop our own custom-behaved number classes. Here, the idea of imitating number classes is put into use. We can create objects that can be used in the same way as native numeric classes by simulating them using special methods (also called "magic methods" or "dunder methods"). Basic Addition with __add__ The simplest way to emulate numeric behavior is implementing the __add__ method − class MyNumber: def __init__(self, value): ...
Read MoreDifference Between Set vs List vs Tuple
Python provides three essential data structures for storing collections: lists, tuples, and sets. Each serves different purposes with unique characteristics that make them suitable for specific use cases. List A list is a mutable, ordered collection that allows duplicate elements. Items can be changed, added, or removed after creation ? # Create a list fruits = ['apple', 'banana', 'orange'] print("Original list:", fruits) # Access elements by index print("First fruit:", fruits[0]) # Add elements fruits.append('kiwi') print("After append:", fruits) # Remove elements fruits.remove('banana') print("After removal:", fruits) # Check membership print("Is 'apple' in list?", 'apple' ...
Read MoreHashing Passwords in Python with BCrypt
Password hashing is a technique used to store passwords securely. It involves converting plain text passwords into a hashed format that cannot be easily reversed or decrypted. By hashing passwords, even if a hacker gains access to the password database, they will not be able to decipher the passwords. BCrypt is a password hashing algorithm that is considered one of the most secure algorithms for password hashing in Python. BCrypt is designed to be slow, which makes it more difficult for hackers to crack the hashed passwords. Installation First, install the BCrypt library using pip: ...
Read MoreHandling Categorical Data in Python
Data that only includes a few values is referred to as categorical data, often known as categories or levels. It is described in two ways − nominal or ordinal. Data that lacks any intrinsic order, such as colors, genders, or animal species, is represented as nominal categorical data. Ordinal categorical data refers to information that is naturally ranked or ordered, such as customer satisfaction levels or educational attainment. Setup Install the required libraries for handling categorical data ? pip install pandas pip install scikit-learn pip install category_encoders Categorical data is often represented as text ...
Read MoreFun Fact Generator Web App in Python
Flask is a lightweight Python web framework that makes it easy to build web applications. In this tutorial, we'll create a Fun Fact Generator web app that displays random interesting facts to users. This project demonstrates Flask basics including routing, templates, and dynamic content generation. Prerequisites and Setup Before starting, ensure you have Python 3.x installed. Install Flask using pip − pip install flask Create the following project structure − Project Folder/ ├── app.py └── templates/ └── index.html How It Works Our Fun Fact Generator ...
Read Morefromtimestamp() Function Of Datetime.date Class in Python
The fromtimestamp() function of the Python datetime.date class converts a Unix timestamp into a date object. A timestamp represents the duration since the epoch (January 1, 1970, 00:00:00 UTC). This function is particularly useful when working with databases, log files, or APIs that store dates as timestamps. Syntax datetime.date.fromtimestamp(timestamp) The method takes a single parameter − the timestamp value in seconds − and returns a date object. Since it's a class method, you must call it using the class name datetime.date. Basic Example import datetime # Create a timestamp value (January ...
Read MoreFood Recognition Selenium using Calorie Mama API
Selenium WebDriver is an open-source automation tool for web browsers that provides a platform-independent testing framework. When combined with the Calorie Mama API, which uses deep learning and computer vision algorithms to recognize food items and their nutritional values from images, we can automate food recognition tasks. In this tutorial, we'll explore how to use Selenium WebDriver to automate the process of uploading food images to the Calorie Mama API and retrieving nutritional information programmatically. Prerequisites and Setup Firefox Browser Installation Download Firefox from the official website Install Firefox, which will be placed in C:\Program ...
Read More