
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
752 Views
To count distinct, use nunique in Pandas. We will groupby a column and find sun as well using Numpy sum().At first, import the required libraries −import pandas as pd import numpy as npCreate a DataFrame with 3 columns. The columns have duplicate values −dataFrame = pd.DataFrame( { ... Read More

AmitDiwan
747 Views
To remove duplicate values from a Pandas DataFrame, use the drop_duplicates() method. At first, create a DataFrame with 3 columns −dataFrame = pd.DataFrame({'Car': ['BMW', 'Mercedes', 'Lamborghini', 'BMW', 'Mercedes', 'Porsche'], 'Place': ['Delhi', 'Hyderabad', 'Chandigarh', 'Delhi', 'Hyderabad', 'Mumbai'], 'UnitsSold': [95, 70, 80, 95, 70, 90]})Remove duplicate values −dataFrame = dataFrame.drop_duplicates() ExampleFollowing is ... Read More

AmitDiwan
2K+ Views
We will consider an example of Car Sale Records and group month-wise to calculate the sum of Registration Price of car monthly. To sum, we use the sum() method.At first, let’s say the following is our Pandas DataFrame with three columns −dataFrame = pd.DataFrame( { "Car": ... Read More

AmitDiwan
780 Views
To generate dates in a range, use the date _range() method. At first, import the required pandas library with an alias −import pandas as pdNow, let’s say you need to generate dates in arrange, therefore for this, mention the date from where you want to begin. Here, we have mentioned ... Read More

AmitDiwan
384 Views
To convert string data to actual dates i.e. datetime type, use the to_datetime() method. At first, let us create a DataFrame with 3 categories, one of the them is a date string −dataFrame = pd.DataFrame({ 'Product Category': ['Computer', 'Mobile Phone', 'Electronics', 'Stationery'], 'Product Name': ['Keyboard', 'Charger', 'SmartTV', ... Read More

AmitDiwan
157 Views
To compute last of group values, use the groupby.last() method. At first, import the required library with an alias −import pandas as pd;Create a DataFrame with 3 columns −dataFrame = pd.DataFrame( { "Car": ['BMW', 'Lexus', 'BMW', 'Tesla', 'Lexus', 'Tesla'], "Place": ['Delhi', 'Bangalore', 'Pune', 'Punjab', 'Chandigarh', 'Mumbai'], ... Read More

AmitDiwan
871 Views
To filter on the basis of sum of columns, we use the loc() method. Here, in our example, we sum the marks of each student to get the student column with marks above 400 i.e. 80%.At first, create a DataFrame with student records. We have marks records of 3 students ... Read More

AmitDiwan
196 Views
To select first periods of time series based on a date offset, use the first() method. At first, set the date index with periods and freq parameters. Freq is for frequency −i = pd.date_range('2021-07-15', periods=5, freq='3D')Now, create a DataFrame with above index −dataFrame = pd.DataFrame({'k': [1, 2, 3, 4, 5]}, ... Read More

AmitDiwan
5K+ Views
To merge Pandas DataFrame, use the merge() function. In that, you can set the parameter indicator to True or False. If you want to check which dataframe has a specific record, then use −indicator= TrueAs shown above, using above parameter as True, adds a column to the output DataFrame called ... Read More

AmitDiwan
788 Views
To calculate the standard deviation, use the std() method of the Pandas. 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, ... Read More