
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
Found 10476 Articles for Python

372 Views
To check if any specific column of two DataFrames are equal or not, use the equals() method. Let us first create DataFrame1 with two columns −dataFrame1 = pd.DataFrame( { "Car": ['BMW', 'Lexus', 'Audi', 'Mustang', 'Bentley', 'Jaguar'], "Units": [100, 150, 110, 80, 110, 90] } )Create DataFrame2 with two columns −dataFrame2 = pd.DataFrame( { "Car": ['BMW', 'Lexus', 'Audi', 'Mustang', 'Mercedes', 'Jaguar'], "Units": [100, 150, 110, 80, 110, 90] ... Read More

751 Views
To calculate the mean of column values, use the mean() method. 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] } )Finding the mean of a single column “Units” using mean() −print"Mean of Units column from DataFrame1 = ", dataFrame1['Units'].mean()In the same way, we have calculated the mean value from the 2nd DataFrame.ExampleFollowing is the complete code −import pandas ... Read More

296 Views
To create a pipeline in Pandas, we need to use the pipe() method. At first, import the required pandas library with an alias −import pandas as pdNow, create a DataFrame −dataFrame = pd.DataFrame( { "Car": ['BMW', 'Lexus', 'Audi', 'Mustang', 'Bentley', 'Jaguar'], "Units": [100, 150, 110, 80, 110, 90] } ) Create a pipeline and call the upperFunc() custom function to convert column names to uppercase −pipeline = dataFrame.pipe(upperFunc)Following is the upperFun() to convert column names to uppercase −def upperFunc(dataframe): # Converting ... Read More

548 Views
To concatenate multiindex into single index, at first, let us import the required Pandas and Numpy libraries with their respective aliases −import pandas as pd import numpy as np Create Pandas series −d = pd.Series([('Jacob', 'North'), ('Ami', 'East'), ('Ami', 'West'), ('Scarlett', 'South'), ('Jacob', 'West'), ('Scarlett', 'North')])Now, use the Numpy arrange() method −dataFrame = pd.Series(np.arange(1, 7), index=d) Let us now map and join −dataMap = dataFrame.index.map('_'.join)ExampleFollowing is the code −import pandas as pd import numpy as np # pandas series d = pd.Series([('Jacob', 'North'), ('Ami', 'East'), ('Ami', 'West'), ('Scarlett', 'South'), ('Jacob', 'West'), ('Scarlett', 'North')]) dataFrame = pd.Series(np.arange(1, 7), ... Read More

175 Views
To typecast pandas into Set, use the set(). At first, let us create a DataFrame −dataFrame = pd.DataFrame( { "EmpName": ['John', 'Ted', 'Jacob', 'Scarlett', 'Ami', 'Ted', 'Scarlett'], "Zone": ['North', 'South', 'South', 'East', 'West', 'East', 'North'] } ) Typecast pandas to set and then take set union −set(dataFrame.EmpName) | set(dataFrame.Zone)ExampleFollowing is the complete code − import pandas as pd # Create DataFrame dataFrame = pd.DataFrame( { "EmpName": ['John', 'Ted', 'Jacob', 'Scarlett', 'Ami', ... Read More

6K+ Views
To find unique values from multiple columns, use the unique() method. Let’s say you have Employee Records with “EmpName” and “Zone” in your Pandas DataFrame. The name and zone can get repeated since two employees can have similar names and a zone can have more than one employee. In that case, if you want unique Employee names, then use the unique() for DataFrame.At first, import the required library. Here, we have set pd as an alias −import pandas as pdAt first, create a DataFrame. Here, we have two columns −dataFrame = pd.DataFrame( { "EmpName": ['John', 'Ted', ... Read More

4K+ Views
Let us begin by learning about the digital certificate.Digital CertificateIt is basically a certificate issued digitally, issued to verify a user's authenticity i.e., verifying the user sending a message is who he or she claims to be, and also to provide the receiver with the means to encode a reply.Whoever wants to or an individual who wants to send encrypted messages applies for a digital certificate from a Certificate Authority (CA).Need of digital certificateThe digital certificate allows entities to share their public key in an authenticated way. They are used in initializing and establishing secure SSL (Secure Sockets Layer) connections ... Read More

2K+ Views
Let us understand the symmetric key encryption.Symmetric Key encryptionSymmetric-key encryption algorithms in cryptography use a single key or the same cryptographic keys (secret key) shared between the two parties for both encrypting plain-text and decrypting cipher-text. The keys could be identical or there could be a simple change to go between the two keys.It uses Diffie–Hellman key exchange or other public-key protocol to securely agree upon the sharing and usage of a fresh new secret key for each message.Asymmetric Key encryptionAsymmetric key encryption is an encryption technique using a pair of public and private keys to encrypt and decrypt plain-text ... Read More

3K+ Views
To find the uncommon rows between two DataFrames, use the concat() method. Let us first import the required library with alias −import pandas as pdCreate DataFrame1 with two columns −dataFrame1 = pd.DataFrame( { "Car": ['BMW', 'Lexus', 'Audi', 'Tesla', 'Bentley', 'Jaguar'], "Reg_Price": [1000, 1500, 1100, 800, 1100, 900] } )Create DataFrame2 with two columns −dataFrame2 = pd.DataFrame( { "Car": ['BMW', 'Lexus', 'Audi', 'Tesla', 'Bentley', 'Jaguar'], "Reg_Price": [1000, 1300, ... Read More

8K+ Views
We can use the shift() method in Pandas to shift the columns of a DataFrame without having to rewrite the whole DataFrame. shift() takes the following parametersshift(self, periods=1, freq=None, axis=0, fill_value=None)periods Number of periods to shift. It can take a negative number too.axis It takes a Boolean value; 0 if you want to shift index and 1 if you want to shift columnfill_value It will replace the missing value.Let's take an example and see how to use this shift() method.StepsCreate a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.Print the input DataFrame, df.Select a column and shift it by using df["column_name]=df.column_name.shift()Print ... Read More