
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
AmitDiwan has Published 10744 Articles

AmitDiwan
403 Views
To create a subset by choosing specific values from columns based on indexes, use the iloc() method. Let us first import the pandas libraryimport pandas as pdCreate a Pandas DataFrame with Product records. We have 3 columns in itdataFrame = pd.DataFrame({"Product": ["SmartTV", "ChromeCast", "Speaker", "Earphone"], "Opening_Stock": [300, 700, 1200, 1500], ... Read More

AmitDiwan
410 Views
When it is required to assign an alphabet to every element of an integer list, the ‘ascii_lowercase’ method, and the list comprehension are used.ExampleBelow is a demonstration of the same −import string my_list = [11, 51, 32, 45, 21, 66, 12, 58, 90, 0] print("The list is : ... Read More

AmitDiwan
164 Views
When it is required to get the dictionaries with unique value lists, the ‘set’ operator and the list methods are used, along with a simple iteration.ExampleBelow is a demonstration of the same −my_dictionary = [{'Python' : 11, 'is' : 22}, {'fun' : 11, 'to' : 33}, {'learn' : 22}, {'object':9}, ... Read More

AmitDiwan
240 Views
When it is required to get the mean of the matrix elements, the ‘mean’ method from the ‘Numpy’ package is used after it has been imported into the environment.ExampleBelow is a demonstration of the same −import numpy as np my_matrix = np.matrix('[24, 41; 35, 25]') print("The matrix is : ... Read More

AmitDiwan
556 Views
When it is required to extract the value of key if the key is present in the list as well as the dictionary, a simple iteration and the ‘all’ operator are used.ExampleBelow is a demonstration of the same −my_list = ["Python", "is", "fun", "to", "learn", "and", "teach", 'cool', 'object', 'oriented'] ... Read More

AmitDiwan
452 Views
When it is required to sort the list of dictionary based on the key’s ‘i’th index value, the ‘sorted’ method and the lambda methods are used.ExampleBelow is a demonstration of the same −my_list = [{"Python" : "Best", "to" : "Code"}, {"Python" : "Good", "to" : "Learn"}, ... Read More

AmitDiwan
267 Views
When it is required to check if the splits in a string are equal, the ‘len’ method, ‘list’ method and the ‘set’ operator are used along with an ‘if’ condition.ExampleBelow is a demonstration of the same −my_string = '96%96%96%96%96%96' print("The string is : " ) print(my_string) my_split_char = ... Read More

AmitDiwan
3K+ Views
To drop a level from a multi-level column index, use the columns.droplevel(). We have used the Multiindex.from_tuples() is used to create indexes column-wise.At first, create indexes column-wise −items = pd.MultiIndex.from_tuples([("Col 1", "Col 1", "Col 1"), ("Col 2", "Col 2", "Col 2"), ("Col 3", "Col 3", "Col 3")])Next, create a multiindex ... Read More

AmitDiwan
216 Views
When it is required to get the grouped consecutive range of indices of elements in a list, a defaultdict is created. A simple iteration, along with ‘groupby’ method, ‘len’ method, ‘list’ method and the ‘append’ methods are used.ExampleBelow is a demonstration of the same −from itertools import groupby from collections ... Read More

AmitDiwan
426 Views
When it is required to split the strings based on the occurrence of the prefix, two empty lists are defined, and a prefix value is defined. A simple iteration is used along with ‘append’ method.ExampleBelow is a demonstration of the same −from itertools import zip_longest my_list = ["hi", 'hello', ... Read More