
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
851 Views
To sort data in ascending or descending order, use sort_values() method. For ascending order, use the following is the sort_values() method −ascending=TrueImport the required library −import pandas as pd Create a DataFrame with 3 columns −dataFrame = pd.DataFrame( { "Car": ['BMW', 'Lexus', 'BMW', 'Mustang', 'Mercedes', 'Lexus'], ... Read More

AmitDiwan
527 Views
To get the maximum of column values, use the max() function. At first, import the required Pandas library −import pandas as pdNow, create a DataFrame with two columns −dataFrame1 = pd.DataFrame( { "Car": ['BMW', 'Lexus', 'Audi', 'Tesla', 'Bentley', 'Jaguar'], "Units": [100, 150, 110, 80, 110, 90] ... Read More

AmitDiwan
464 Views
When it is required to sort the palindrome words present in a sentence, a method is defined that takes a string as a parameter and first ensures that it is a palindrome. Then it sorts all the words of a string and returns it as output.ExampleBelow is a demonstration of ... Read More

AmitDiwan
864 Views
When it is required to generate all possible permutations of a word in a sentence, a function is defined. This function iterates over the string and depending on the condition, the output is displayed.ExampleBelow is a demonstration of the samefrom itertools import permutations def calculate_permutations(my_string): my_list = list(my_string.split()) ... Read More

AmitDiwan
4K+ Views
Use index=False to ignore index. Let us first import the required library −import pandas as pdCreate a DataFrame −dataFrame = pd.DataFrame([[10, 15], [20, 25], [30, 35]], index=['x', 'y', 'z'], columns=['a', 'b'])Select rows by passing label using loc −dataFrame.loc['x'] Display DataFrame without index −dataFrame.to_string(index=False)ExampleFollowing is the code −import pandas as pd ... Read More

AmitDiwan
184 Views
When it is required to extract rows from a matrix with different data types, it is iterated over and ‘set’ is used to get the distinct types.ExampleBelow is a demonstration of the samemy_list = [[4, 2, 6], ["python", 2, {6: 2}], [3, 1, "fun"], [9, (4, 3)]] print("The list ... Read More

AmitDiwan
400 Views
When it is required to split the list into all the possible tuple pairs, a method can be defined that takes a list as a parameter and uses list comprehension to iterate through the list and use ‘extend’ methodExampleBelow is a demonstration of the samedef determine_pairings(my_list): if ... Read More

AmitDiwan
189 Views
When it is required to reverse a given range in a list, it is iterated over and the ‘:’ operator along with slicing is used to reverse it.ExampleBelow is a demonstration of the samemy_list = ["Hi", "there", "how", 'are', 'you'] print("The list is : ") print(my_list) m, n ... Read More

AmitDiwan
296 Views
When it is required to find the cumulative mean of the dictionary keys, an empty dictionary is created, and the original dictionary is iterated over, and the items are accessed. If this is present in the dictionary, the key is appended to the empty dictionary, otherwise the value is placed ... Read More

AmitDiwan
5K+ Views
For mean, use the mean() function. Calculate the mean for the column with NaN and use the fillna() to fill the NaN values with the mean.Let us first import the required libraries −import pandas as pd import numpy as npCreate a DataFrame with 2 columns and some NaN values. We ... Read More