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 935 of 2650
5K+ Views
To sum only specific rows, use the loc() method. Mention the beginning and end row index using the : operator. Using loc(), you can also set the columns to be included. We can display the result in a new column.At first, let us create a DataFrame. We have Product records in it, including the Opening and Closing Stock −dataFrame = pd.DataFrame({"Product": ["SmartTV", "ChromeCast", "Speaker", "Earphone"], "Opening_Stock": [300, 700, 1200, 1500], "Closing_Stock": [200, 500, 1000, 900]})Sum of some rows i.e. 1st two rows. Column names also mentioned in the loc() i.e. Opening_Stock and Closing_Stock. We are displaying result in a new ... Read More
689 Views
To calculate the median of column values, use the median() 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 median of a single column “Units” using median() −print"Median of Units column from DataFrame1 = ", dataFrame1['Units'].median() In the same way, we have calculated the median value from the 2nd DataFrame.ExampleFollowing is the complete code ... Read More
5K+ Views
To find the common rows between two DataFrames, use the merge() method. Let us first create DataFrame1 with two columns −dataFrame1 = pd.DataFrame( { "Car": ['BMW', 'Lexus', 'Audi', 'Tesla', 'Bentley', 'Jaguar'], "Units": [100, 150, 110, 80, 110, 90] } )Create DataFrame2 with two columns −dataFrame2 = pd.DataFrame( { "Car": ['BMW', 'Lexus', 'Audi', 'Mustang', 'Bentley', 'Jaguar'], "Units": [100, 250, 150, 80, 130, 90] } )To find the common ... Read More
376 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
758 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
306 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
556 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
181 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