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
Programming Articles - Page 1074 of 3363
316 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
569 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
200 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
88K+ Views
To append the rows of one dataframe with the rows of another, we can use the Pandas append() function. With the help of append(), we can append columns too. Let's take an example and see how to use this method.StepsCreate a two-dimensional, size-mutable, potentially heterogeneous tabular data, df1.Print the input DataFrame, df1.Create another DataFrame, df2, with the same column names and print it.Use the append method, df1.append(df2, ignore_index=True), to append the rows of df2 with df2.Print the resultatnt DataFrame.Exampleimport pandas as pd df1 = pd.DataFrame({"x": [5, 2], "y": [4, 7], "z": [9, 3]}) df2 = pd.DataFrame({"x": [1, 3], "y": ... Read More
43K+ Views
To get the nth row in a Pandas DataFrame, we can use the iloc() method. For example, df.iloc[4] will return the 5th row because row numbers start from 0.StepsMake two-dimensional, size-mutable, potentially heterogeneous tabular data, df.Print input DataFrame, df.Initialize a variable nth_row.Use iloc() method to get nth row.Print the returned DataFrame.Exampleimport pandas as pd df = pd.DataFrame( dict( name=['John', 'Jacob', 'Tom', 'Tim', 'Ally'], marks=[89, 23, 100, 56, 90], subjects=["Math", "Physics", "Chemistry", "Biology", "English"] ) ) ... Read More