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
Server Side Programming Articles - Page 936 of 2650
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
7K+ Views
To find numeric columns in Pandas, we can make a list of integers and then include it into select_dtypes() method. Let's take an example and see how to apply this method.StepsCreate a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.Print the input DataFrame, df.Make a list of data type, i.e., numerics, to select a column.Return a subset of the DataFrame's columns based on the column dtypes.Print the column whose data type is int.Example import pandas as pd df = pd.DataFrame( dict( name=['John', 'Jacob', 'Tom', 'Tim', 'Ally'], ... Read More
29K+ Views
To find the maximum value of a column and to return its corresponding row values in Pandas, we can use df.loc[df[col].idxmax()]. Let's take an example to understand it better.StepsCreate a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.Print the input DataFrame, df.Initialize a variable, col, to find the maximum value of that column.Find the maximum value and its corresponding row, using df.loc[df[col].idxmax()]Print the Step 4 output.Exampleimport pandas as pd df = pd.DataFrame( { "x": [5, 2, 7, 0], "y": [4, 7, 5, 1], "z": [9, 3, 5, 1] } ... Read More
32K+ Views
We can use the .corr() method to get the correlation between two columns in Pandas. Let's take an example and see how to apply this method.StepsCreate a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.Print the input DataFrame, df.Initialize two variables, col1 and col2, and assign them the columns that you want to find the correlation of.Find the correlation between col1 and col2 by using df[col1].corr(df[col2]) and save the correlation value in a variable, corr.Print the correlation value, corr.Exampleimport pandas as pd df = pd.DataFrame( { "x": [5, 2, 7, 0], "y": [4, ... Read More
18K+ Views
A regular expression (regex) is a sequence of characters that define a search pattern. To filter rows in Pandas by regex, we can use the str.match() method.StepsCreate a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.Print the input DataFrame, df.Initialize a variable regex for the expression. Supply a string value as regex, for example, the string 'J.*' will filter all the entries that start with the letter 'J'.Use df.column_name.str.match(regex) to filter all the entries in the given column name by the supplied regex.Example import pandas as pd df = pd.DataFrame( dict( name=['John', 'Jacob', 'Tom', 'Tim', 'Ally'], ... Read More
4K+ Views
It's quite simple to rename a DataFrame column name in Pandas. All that you need to do is to use the rename() method and pass the column name that you want to change and the new column name. Let's take an example and see how it's done.StepsCreate a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.Print the input DataFrame, df.Use rename() method to rename the column name. Here, we will rename the column "x" with its new name "new_x".Print the DataFrame with the renamed column.Example import pandas as pd df = pd.DataFrame( { "x": [5, 2, ... Read More