Tapas Kumar Ghosh

Tapas Kumar Ghosh

185 Articles Published

Articles by Tapas Kumar Ghosh

Page 7 of 19

How to search a value within a Pandas DataFrame row?

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 27-Mar-2026 4K+ Views

Pandas DataFrame is a two-dimensional data structure that represents data in tabular form with rows and columns. Python provides several built-in methods like eq(), any(), loc[], and apply() to search for specific values within DataFrame rows. Basic Value Search in a Column The simplest approach is to search for a value in a specific column using boolean indexing ? import pandas as pd # Create a DataFrame data = {'Name': ['Bhavish', 'Abhinabh', 'Siddhu'], 'Age': [25, 32, 28]} df = pd.DataFrame(data) # Search for a value in ...

Read More

How to sort by value in PySpark?

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 27-Mar-2026 935 Views

PySpark is a distributed data processing engine that provides Python APIs for Apache Spark. It enables large-scale data processing and offers several built-in functions for sorting data including orderBy(), sort(), sortBy(), and asc_nulls_last(). Installation First, install PySpark using pip ? pip install pyspark Key Sorting Functions Function Usage Best For orderBy() DataFrame column sorting Single/multiple columns with custom order sort() DataFrame sorting with functions Descending order and null handling sortBy() RDD sorting with lambda Custom sorting logic on RDDs Sorting DataFrame by ...

Read More

How to Skip every Nth index of Numpy array?

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 27-Mar-2026 2K+ Views

In NumPy arrays, you can skip every Nth index using several approaches: modulus operations with np.mod(), array slicing, or loop-based filtering. These techniques are useful for data sampling, filtering, and array manipulation tasks. Understanding the Modulus Approach The modulus approach uses np.mod() to identify which indices to skip. It works by calculating the remainder when dividing each index by N, then filtering elements where the remainder is not zero. import numpy as np # Create a sample array x = np.array([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140]) ...

Read More

How to Set a Single Main Title for All the Subplots in Matplotlib?

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 27-Mar-2026 5K+ Views

When creating multiple subplots in Matplotlib, you often need a single main title that spans across all subplots. The suptitle() function provides an elegant solution for setting a main title above all subplots in a figure. Syntax The basic syntax for setting a main title across subplots − plt.suptitle('Main Title Text') # or fig.suptitle('Main Title Text') Basic Example with Line Plots Let's create a 2x2 grid of subplots with different mathematical functions and a single main title − import numpy as np import matplotlib.pyplot as plt # Create data x ...

Read More

How to set up Python mode for Processing

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 27-Mar-2026 453 Views

Python Mode for Processing is an add-on that enables Python programming within the Processing IDE, a development environment designed for visual arts and creative coding. This mode allows developers to leverage Python's simplicity while creating interactive visual programs and animations. System Requirements Component Minimum Requirement RAM 4GB (8GB recommended) CPU 64-bit processor Disk Space 2GB free space Screen Resolution 1024 x 768 or higher Operating System Windows, macOS, Linux, Raspberry Pi Installation Steps Step 1: Download Processing Visit the official Processing ...

Read More

How to set up anaconda path to environment variable?

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 27-Mar-2026 8K+ Views

Anaconda is a free, open-source Python distribution that includes a comprehensive package management system and environment manager. It comes with over 1000+ data science packages and tools like Jupyter Notebook, Spyder, and JupyterLab. Setting up Anaconda's path in environment variables allows you to access Python and conda commands from any terminal or command prompt. System Requirements Requirement Details RAM 8GB recommended ...

Read More

How to slice a 3D Tensor in Pytorch?

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 27-Mar-2026 2K+ Views

A 3D Tensor in PyTorch is a three-dimensional array containing matrices, while 1D and 2D tensors represent vectors and matrices respectively. PyTorch provides various methods to slice 3D tensors using indexing operations and built-in functions like split(). Basic Tensor Slicing Syntax PyTorch uses standard Python indexing with the format tensor[dim1, dim2, dim3] where each dimension can use slice notation ? import torch # Create a 3D tensor with shape (2, 3, 4) tensor_3d = torch.randn(2, 3, 4) print("Original tensor shape:", tensor_3d.shape) print(tensor_3d) Original tensor shape: torch.Size([2, 3, 4]) tensor([[[-0.5234, 1.2341, -0.8765, ...

Read More

How to skip rows while reading csv file using Pandas

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 27-Mar-2026 3K+ Views

Python's Pandas library provides the read_csv() function to read CSV files with flexible options for skipping rows. This is useful for data cleaning, removing headers, or filtering specific rows during data import. Syntax pandas.read_csv('filename.csv', skiprows=condition) Parameters: filename.csv − Path to the CSV file skiprows − Rows to skip. Can be an integer, list, or lambda function Creating Sample Data Let's create a sample CSV file for demonstration ? import pandas as pd # Create sample data data = { 'Name': ['Alice', 'Bob', 'Charlie', ...

Read More

How to Show Values on Seaborn Barplot?

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 27-Mar-2026 7K+ Views

A Seaborn barplot displays the average value of a numerical variable with error bars indicating the range around the mean. Adding values directly on bars makes data interpretation easier and more precise. Key Functions The main functions used for displaying values on Seaborn barplots are: sns.barplot() − Creates the bar chart enumerate() − Adds counter to iterate over data ax.text() − Adds text labels to specific positions plt.show() − Displays the final plot Method 1: Values Above Bars Position text labels above each bar for clear visibility ? import seaborn as ...

Read More

Python Program to display date in different country format

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 27-Mar-2026 1K+ Views

In Python, we can display dates and times in different country formats using built-in modules like datetime and pytz. These modules provide functions such as datetime.now(), utcnow(), astimezone(), and strftime() to handle timezone conversions and formatting. Key Functions datetime.now() − Returns the current local date and time. utcnow() − Returns the current UTC (Coordinated Universal Time) datetime. astimezone() − Converts datetime to a specified timezone. strftime() − Formats datetime as a string using format codes. Method 1: Using datetime and pytz The most common approach uses the datetime and pytz modules for timezone ...

Read More
Showing 61–70 of 185 articles
« Prev 1 5 6 7 8 9 19 Next »
Advertisements