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 on Trending Technologies
Technical articles with clear explanations and examples
Python Pandas – How to use Pandas DataFrame Property: shape
The shape property in Pandas DataFrame returns a tuple containing the number of rows and columns. It's essential for understanding your dataset dimensions before performing data analysis operations. DataFrame.shape Property The shape property returns (rows, columns) as a tuple. You can access individual values using indexing ? # Basic syntax df.shape # Returns (rows, columns) df.shape[0] # Number of rows df.shape[1] # Number of columns Creating Sample Data Let's create a sample products dataset to demonstrate the shape ...
Read MoreMake three numbers Zero in Python
Let us suppose we have three numbers. The task is to count the total number of optimal steps to make all these numbers zero by repeatedly removing 1 from any two numbers at a time. Problem Statement Given three numbers, find the minimum number of steps to make all three numbers zero, where in each step you can subtract 1 from any two numbers. Example Input: a = 4 b = 4 c = 6 Output: 7 Step-by-step explanation: Initial state: (4, 4, 6) Step 1: Remove ...
Read MoreLargest Merge of Two Strings in Python
When merging two strings, we want to create the lexicographically largest possible result by choosing characters strategically. This problem involves comparing entire remaining substrings at each step to make optimal choices. Problem Understanding Given two strings a and b, we need to merge them by repeatedly choosing which string to take the next character from. The key rule is: always choose from the string whose remaining portion is lexicographically larger. Algorithm Steps Compare the remaining portions of both strings Take the first character from the lexicographically larger string Repeat until both strings are empty Append ...
Read MoreCopy list with random Pointer in Python
A Linked List with Random Pointers is a data structure where each node contains data, a next pointer, and an additional random pointer that can point to any node in the list. Creating a deep copy of such a list requires preserving both the structure and random pointer relationships. The challenge is to copy not just the values and next pointers, but also maintain the correct random pointer connections in the new list. Problem Example Consider a linked list where each node has a random pointer: 1 ...
Read MoreBreadth First Search on Matrix in Python
Breadth First Search (BFS) on a matrix finds the shortest path between two cells by exploring neighbors level by level. In a 2D matrix, each cell can move in four directions: left, right, up, and down. Matrix Cell Types In BFS matrix problems, cells are typically represented by different values ? 0 − Blocked cell (cannot move through) 1 − Open cell (can move through) 2 − Source cell (starting point) 3 − Destination cell (target point) BFS Algorithm for Matrix The algorithm uses a queue to explore cells level by level ? ...
Read MoreBalanced Binary Tree in Python
In a binary tree, each node contains two children, i.e left child and right child. Let us suppose we have a binary tree and we need to check if the tree is balanced or not. A Binary tree is said to be balanced if the difference of height of left subtree and right subtree is less than or equal to 1. Problem Examples Example 1 - Balanced Tree 1 2 ...
Read MorePython Pandas - Read data from a CSV file and print the 'product' column value that matches 'Car' for the first ten rows
When working with CSV data in Pandas, you often need to filter specific rows based on column values. This tutorial shows how to read a CSV file and filter rows where the 'product' column matches 'Car' from the first ten rows. We'll use the 'products.csv' file which contains 100 rows and 8 columns with product information. Sample Data Structure The products.csv file contains the following structure ? Rows: 100 Columns: 8 id product engine avgmileage price height_mm width_mm productionYear 1 2 ...
Read MoreHow can Tensorflow be used to compose layers using Python?
TensorFlow allows you to compose layers by creating custom models that inherit from tf.keras.Model. This approach enables you to build complex architectures like ResNet identity blocks by combining multiple layers into reusable components. Understanding Layer Composition Layer composition in TensorFlow involves creating custom models that encapsulate multiple layers. This is particularly useful for building residual networks where you need to combine convolutional layers, batch normalization, and skip connections into a single reusable block. Creating a ResNet Identity Block Here's how to compose layers by creating a ResNet identity block that combines multiple convolutional and batch normalization ...
Read MoreHow can Tensorflow be used to plot the results using Python?
TensorFlow can be used to plot results using the matplotlib library and imshow method. This is particularly useful for visualizing predictions from image classification models and displaying multiple images in a grid format. Read More: What is TensorFlow and how Keras work with TensorFlow to create Neural Networks? Transfer Learning and Visualization Transfer learning allows us to use pre-trained models from TensorFlow Hub for image classification without training from scratch. The intuition behind transfer learning is that if a model is trained on a large and general dataset, it can serve as a generic model for the ...
Read MoreHow can Tensorflow be used to check the predictions using Python?
TensorFlow can be used to check predictions using the predict() method and NumPy's argmax() method. This approach is commonly used in image classification tasks where you need to determine the most likely class for input data. Read More: What is TensorFlow and how Keras work with TensorFlow to create Neural Networks? The intuition behind transfer learning for image classification is that if a model is trained on a large and general dataset, this model can effectively serve as a generic model for the visual world. It learns feature maps, meaning you don't have to start from scratch by ...
Read More