Pradeep Elance

Pradeep Elance

317 Articles Published

Articles by Pradeep Elance

Page 32 of 32

Accessing elements of a Pandas Series

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 11K+ Views

A Pandas Series is a one-dimensional labeled array that can hold any data type. Elements can be accessed using integer position, custom index labels, or slicing. Creating a Series import pandas as pd s = pd.Series([11, 8, 6, 14, 25], index=['a', 'b', 'c', 'd', 'e']) print(s) a 11 b 8 c 6 d 14 e 25 dtype: int64 Accessing a Single Element Use integer position or custom label to access individual elements ? ...

Read More

a.sort, sorted(a), np_argsort(a) and np.lexsort(b, a) in Python

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 805 Views

Python provides built-in sorting functions (sorted(), list.sort()) and NumPy provides advanced sorting (np.argsort(), np.lexsort()) for working with arrays and multiple sort keys. sorted() Returns a new sorted list without modifying the original ? a = [9, 5, 3, 1, 12, 6] b = sorted(a) print("Sorted Array:", b) print("Original Array:", a) Sorted Array: [1, 3, 5, 6, 9, 12] Original Array: [9, 5, 3, 1, 12, 6] list.sort() Sorts the list in-place (modifies the original, returns None). Faster than sorted() since it doesn't create a copy ? a = ...

Read More

Absolute and Relative Imports in Python

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 784 Views

In Python, when you need to access code from another file or package, you use import statements. There are two approaches − absolute imports (full path from the project root) and relative imports (path relative to the current file). How Python Resolves Imports When Python encounters an import statement, it searches in this order − Module cache − Checks sys.modules for previously imported modules. Built-in modules − Searches Python's standard library. sys.path − Searches directories in sys.path (current directory first). If not found anywhere, raises ModuleNotFoundError. Import Order Convention Import statements should be ...

Read More

Nested list comprehension in python

Pradeep Elance
Pradeep Elance
Updated on 11-Mar-2026 2K+ Views

A nested list is a list within a list. Python provides features to handle nested list gracefully and apply common functions to manipulate the nested lists. In this article we will see how to use list comprehension to create and use nested lists in python.Creating a MatrixCreating a matrix involves creating series of rows and columns. We can use for loop for creating the matrix rows and columns by putting one python list with for loop inside another python list with for loop.Examplematrix = [[m for m in range(4)] for n in range(3)] print(matrix)Running the above code gives us the ...

Read More

Find minimum of each index in list of lists in Python

Pradeep Elance
Pradeep Elance
Updated on 11-Mar-2026 2K+ Views

In some problems we need to identify the minimum of each element in a list. But in solving the matrix operations, we need to find the minimum of each column in the matrix. That needs us to find the minimum value from list of lists. Because each column of a matrix is a list of lists.Using min() and zip()In the below example we use the min() and zip(). Here the zip() function organizes the elements at the same index from multiple lists into a single list. Then we apply the min() function to the result of zip function using a ...

Read More

after method in Python Tkinter

Pradeep Elance
Pradeep Elance
Updated on 02-Jan-2020 3K+ Views

Tkinter is a python library to make GUIs. It has many built in methods to create and manipulate GUI windows and other widgets to show the data and GUI events. In this article we will see how the after method is used in a Tkinter GUI.Syntax.after(delay, FuncName=FuncName) This method calls the function FuncName after the given delay in milisecondDisplaying WidgetHere we make a frame to display a list of words randomly. We use the random library along with the after method to call a function displaying a given list of text in a random manner.Exampleimport random from tkinter import * ...

Read More

Python Program to print the diamond shape

Pradeep Elance
Pradeep Elance
Updated on 30-Dec-2019 489 Views

The looping features in python can be used to create many nicely formatted diagrams using various characters from the keyboard. One such shape is diamond shape which will involve multiple loops. This is because we have to print the character both vertically and horizontally. Also we have to take care of the shape gradually growing from top till middle and then gradually shrinking from middle till the bottom. For this reason, we will use two for loops each containing one more for loop inside it.Below is the code for creating the diamond shape.Exampledef Shape_of_Diamond(shape): a = 0 for m in ...

Read More
Showing 311–317 of 317 articles
« Prev 1 28 29 30 31 32 Next »
Advertisements