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 Tarandeep Singh
5 articles
How to Automate an Excel Sheet in Python?
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 MoreGet the day from a date in Pandas
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 MoreGet the data type of column in Pandas - Python
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 MoreGet tag name using Beautifulsoup in Python
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 MoreGet specific row from PySpark dataframe
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