Programming Articles

Page 127 of 2547

How to Automate an Excel Sheet in Python?

Tarandeep Singh
Tarandeep Singh
Updated on 27-Mar-2026 2K+ Views

Excel automation with Python allows you to manipulate spreadsheets programmatically, saving time and reducing manual errors. Python offers several powerful libraries for Excel automation: openpyxl for direct Excel file manipulation, pandas for data analysis operations, and xlwings for advanced Excel integration. Method 1: Using openpyxl Library The openpyxl library provides direct access to Excel files, allowing you to read, write, and modify spreadsheets cell by cell. Installation pip install openpyxl Example Let's create and manipulate an Excel file that adds bonus calculations to employee salaries − import openpyxl as xl ...

Read More

Get the day from a date in Pandas

Tarandeep Singh
Tarandeep Singh
Updated on 27-Mar-2026 10K+ Views

Pandas provides several methods to extract the day name from dates. Whether you're working with single dates or multiple date strings, you can use dt.dayofweek, dt.day_name(), or dt.strftime() to get day information in different formats. Using dt.dayofweek with Manual Mapping The dt.dayofweek property returns numeric values (0-6) for days, which you can map to day names ? import pandas as pd # Create a date range dates = pd.date_range(start='2022-01-01', end='2022-01-07') # Create a DataFrame with the dates df = pd.DataFrame({'date': dates}) # Add a column with the day of the week as numbers ...

Read More

Get the data type of column in Pandas - Python

Tarandeep Singh
Tarandeep Singh
Updated on 27-Mar-2026 19K+ Views

Pandas is a popular and powerful Python library commonly used for data analysis and manipulation. It offers data structures like Series and DataFrame for working with tabular data. Each column in a Pandas DataFrame can contain a different data type. This article covers various methods for determining column data types in a DataFrame ? Sample DataFrame Let's create a sample DataFrame to demonstrate different approaches ? import pandas as pd # Create a sample dataframe df = pd.DataFrame({ 'Vehicle name': ['Supra', 'Honda', 'Lamborghini'], 'price': [5000000, 600000, ...

Read More

Get tag name using Beautifulsoup in Python

Tarandeep Singh
Tarandeep Singh
Updated on 27-Mar-2026 3K+ Views

BeautifulSoup is one of the most widely used Python packages for web scraping and parsing HTML and XML documents. One of the most common tasks when working with HTML and XML documents is extracting the tag name of specific elements. Python's BeautifulSoup library can be installed using the below command ? pip install beautifulsoup4 Using the name Attribute The most straightforward method to get tag names in BeautifulSoup is using the name attribute of the Tag object. This attribute returns a string value containing the name of the tag. Syntax tag.name ...

Read More

Get specific row from PySpark dataframe

Tarandeep Singh
Tarandeep Singh
Updated on 27-Mar-2026 11K+ Views

PySpark is a powerful tool for big data processing and analysis. When working with PySpark DataFrames, you often need to retrieve specific rows for analysis or debugging. This article explores various methods to get specific rows from PySpark DataFrames using functional programming approaches. Creating Sample DataFrame Let's create a sample DataFrame to demonstrate all the methods ? from pyspark.sql import SparkSession # Create SparkSession spark = SparkSession.builder.appName("get_specific_rows").getOrCreate() # Create sample DataFrame df = spark.createDataFrame([ ('Row1', 1, 2, 3), ('Row2', 4, 5, 6), ...

Read More

Emotion classification using NRC Lexicon in Python

Jaisshree
Jaisshree
Updated on 27-Mar-2026 2K+ Views

Emotion identification or recognition is the ability of a person or system to detect specific emotions from text and categorize them into distinct emotional categories. Unlike traditional sentiment analysis that only classifies text as positive or negative, emotion classification provides deeper insights into human emotions. Emotion Classification in Python using the NRC Lexicon offers a more nuanced approach than basic sentiment analysis. It can identify multiple emotions simultaneously and provides probability scores for each detected emotion. The NRC Emotion Lexicon, developed by the National Research Council of Canada, contains over 27, 000 terms mapped to emotions. It's based ...

Read More

Email + Social Logins in Django - Step-by-Step Guide

Jaisshree
Jaisshree
Updated on 27-Mar-2026 507 Views

Email and social logins are essential authentication methods for modern web applications. Email login requires users to provide their email address and password, while social login allows users to authenticate using their existing accounts from platforms like Google or Facebook. In this tutorial, we'll implement both authentication methods in Django using the Django-allauth package. Installation First, install the django-allauth package using pip ? pip install django-allauth Project Setup Step 1: Configure Settings Add the required configurations to your settings.py file ? # settings.py INSTALLED_APPS = [ ...

Read More

Python program to find the smallest word in a sentence

Siva Sai
Siva Sai
Updated on 27-Mar-2026 746 Views

Welcome to this tutorial on writing a Python program to find the smallest word in a sentence. Whether you are a beginner or intermediate Python programmer, this guide will help you learn text manipulation using Python's built-in functions. Problem Statement Given a sentence, we need to find the word with the fewest characters. In case of a tie, we'll return the first occurring smallest word. Using min() with key Parameter The most efficient approach uses the min() function with a key parameter to compare word lengths ? def find_smallest_word(sentence): # ...

Read More

Python Program to get the subarray from an array using a specified range of indices

Gireesha Devara
Gireesha Devara
Updated on 27-Mar-2026 15K+ Views

An array is a homogeneous data structure used to store elements of the same data type. Each element is identified by a key or index value. Python provides several ways to extract subarrays from arrays using specified index ranges. What is a Subarray? A subarray is a continuous portion of elements from an array. For example, if we have an array: numbers = [9, 3, 1, 6, 9] print("Original array:", numbers) Original array: [9, 3, 1, 6, 9] The possible subarrays include: [9, 3] [9, 3, 1] [3, ...

Read More

Python Program to push an array into another array

Gireesha Devara
Gireesha Devara
Updated on 27-Mar-2026 3K+ Views

In programming, an array is a data structure used to store a collection of homogeneous data elements. Each element is identified by an index value. Python doesn't have a specific array data type, so we use lists as arrays. Arrays in Python Here's how we represent a list as an array ? numbers = [1, 4, 6, 5, 3] print(numbers) [1, 4, 6, 5, 3] Python indexing starts from 0, so elements are accessed using index values 0, 1, 2, 3, 4. Pushing an array into another array means inserting ...

Read More
Showing 1261–1270 of 25,466 articles
« Prev 1 125 126 127 128 129 2547 Next »
Advertisements