Articles on Trending Technologies

Technical articles with clear explanations and examples

Tutorix - AI Tutor

How to rotate a simple matplotlib Axes?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 26-Mar-2026 13K+ Views

To rotate a simple matplotlib axes, we can use the Affine2D transformation along with floating_axes. This technique creates a rotated coordinate system for plotting data at different angles. Required Imports First, import the necessary packages for creating rotated axes ? import matplotlib.pyplot as plt from matplotlib.transforms import Affine2D import mpl_toolkits.axisartist.floating_axes as floating_axes Steps to Rotate Axes The rotation process involves these key steps: Create an affine transformation − Define the rotation angle using Affine2D().rotate_deg() Set axis limits − Define the coordinate range for both x and y axes Create grid helper ...

Read More

How to add a 3d subplot to a matplotlib figure?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 26-Mar-2026 3K+ Views

To add a 3D subplot to a matplotlib figure, you need to specify projection='3d' when creating the subplot. This enables three-dimensional plotting capabilities for visualizing data in 3D space. Basic Steps Follow these steps to create a 3D subplot ? Import matplotlib and numpy libraries Create x, y and z data points Create a figure using plt.figure() Add a subplot with projection='3d' parameter Plot the 3D data using appropriate plotting methods Display the figure with plt.show() Example: Creating a 3D Line Plot Here's how to create a basic 3D line plot ? ...

Read More

How to delete a column from Pandas DataFrame

AmitDiwan
AmitDiwan
Updated on 26-Mar-2026 1K+ Views

To delete a column from a Pandas DataFrame, you have several methods available: del statement, drop() method, and pop() method. Each approach has its own use cases and advantages. Using del Statement The del statement permanently removes a column from the DataFrame ? import pandas as pd # Create DataFrame dataFrame = pd.DataFrame({ "Car": ['BMW', 'Lexus', 'Audi', 'Mustang', 'Bentley', 'Jaguar'], "Units": [100, 150, 110, 80, 110, 90], "Price": [50000, 60000, 45000, 40000, 80000, 70000] }) print("Original DataFrame:") print(dataFrame) # Delete a ...

Read More

Python – Sort Strings by Case difference

AmitDiwan
AmitDiwan
Updated on 26-Mar-2026 262 Views

When working with strings in Python, you may need to sort them based on the case difference — the absolute difference between uppercase and lowercase letters. This technique uses custom sorting with the sort() method and a key function that calculates case differences. Understanding Case Difference Case difference is calculated by counting uppercase and lowercase letters in each string, then finding their absolute difference. Strings with smaller case differences are considered "more balanced" and appear first when sorted. Example Here's how to sort strings by case difference using a custom function ? def get_diff(my_string): ...

Read More

Python – Filter Similar Case Strings

AmitDiwan
AmitDiwan
Updated on 26-Mar-2026 308 Views

When it is required to filter similar case strings, list comprehension can be used along with isupper() and islower() methods. This technique helps identify strings that are either completely uppercase or completely lowercase, filtering out mixed-case strings. Example Below is a demonstration of filtering strings with consistent casing ? my_list = ["Python", "good", "FOr", "few", "CODERS"] print("The list is :") print(my_list) my_result = [sub for sub in my_list if sub.islower() or sub.isupper()] print("The strings with same case are :") print(my_result) Output The list is : ['Python', 'good', 'FOr', 'few', ...

Read More

Python Pandas - How to select rows from a DataFrame by integer location

AmitDiwan
AmitDiwan
Updated on 26-Mar-2026 976 Views

To select rows by integer location in a Pandas DataFrame, use the iloc accessor. The iloc method allows you to select rows and columns by their integer position, starting from 0. Creating a Sample DataFrame Let's start by creating a DataFrame to work with ? import pandas as pd # Create DataFrame dataFrame = pd.DataFrame([[10, 15], [20, 25], [30, 35]], index=['x', 'y', 'z'], ...

Read More

Python – Convert Suffix denomination to Values

AmitDiwan
AmitDiwan
Updated on 26-Mar-2026 322 Views

When working with financial or numerical data, you often encounter values with suffix denominations like "5Cr" (5 Crores), "7M" (7 Million), or "30K" (30 Thousand). Python allows you to convert these suffix notations to their actual numerical values using dictionaries and string manipulation. Example Below is a demonstration of converting suffix denominations to values ? my_list = ["5Cr", "7M", "9B", "12L", "20Tr", "30K"] print("The list is :") print(my_list) value_dict = {"M": 1000000, "B": 1000000000, "Cr": 10000000, "L": 100000, "K": 1000, ...

Read More

Python Pandas - How to select rows from a DataFrame by passing row label

AmitDiwan
AmitDiwan
Updated on 26-Mar-2026 4K+ Views

To select rows by passing a label, use the loc[] accessor in Pandas. You can specify the index label to retrieve specific rows from a DataFrame. The loc[] accessor is label-based and allows you to select data by row and column labels. Creating a DataFrame with Custom Index Labels First, let's create a DataFrame with custom index labels ? import pandas as pd # Create DataFrame with custom index labels dataFrame = pd.DataFrame([[10, 15], [20, 25], [30, 35]], ...

Read More

Python - Cast datatype of only a single column in a Pandas DataFrame

AmitDiwan
AmitDiwan
Updated on 26-Mar-2026 579 Views

In Pandas, you can cast the datatype of only a single column using the astype()

Read More

Python – Check Similar elements in Matrix rows

AmitDiwan
AmitDiwan
Updated on 26-Mar-2026 331 Views

When working with matrices, you might need to identify rows that appear multiple times. Python provides an efficient solution using the Counter class from the collections module to count the frequency of identical rows. Finding Similar Elements in Matrix Rows The approach involves converting matrix rows to tuples (since lists aren't hashable) and using Counter to track row frequencies ? from collections import Counter def find_duplicate_rows(matrix): # Convert rows to tuples for hashing matrix_tuples = map(tuple, matrix) # ...

Read More
Showing 3661–3670 of 61,298 articles
« Prev 1 365 366 367 368 369 6130 Next »
Advertisements