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 1051 of 3363
261 Views
Swarm Plot in Seaborn is used to draw a categorical scatterplot with non-overlapping points. The seaborn.swarmplot() is used for this. Draw swarms of observations on top of a box plot using the seaborn.boxplot().Let’s say the following is our dataset in the form of a CSV file −Cricketers2.csvAt first, import the required libraries −import seaborn as sb import pandas as pd import numpy as np import matplotlib.pyplot as pltLoad data from a CSV file into a Pandas DataFrame −dataFrame = pd.read_csv("C:\Users\amit_\Desktop\Cricketers2.csv") Draw swarms of observations on top of a box plot −sb.boxplot(x = "Matches", y = "Role", data= dataFrame, whis=np.inf) sb.swarmplot(x ... Read More
675 Views
Swarm Plot in Seaborn is used to draw a categorical scatterplot with non-overlapping points. The seaborn.swarmplot() is used for this. Control swarm order by passing an explicit order i.e. ordering on the basis of a specific column using the order parameter −Let’s say the following is our dataset in the form of a CSV file −Cricketers2.csvAt first, import the required libraries −import seaborn as sb import pandas as pd import matplotlib.pyplot as pltLoad data from a CSV file into a Pandas DataFrame −dataFrame = pd.read_csv("C:\Users\amit_\Desktop\Cricketers2.csv") Plotting swarm plot with Academy and Matches. Control swarm order by passing an explicit order ... Read More
458 Views
Swarm Plot in Seaborn is used to draw a categorical scatterplot with non-overlapping points. The seaborn.swarmplot() is used for this. To group the swarms by two categorical variables, set those variables in the swarmplot() using the x, y or hue parameters.Let’s say the following is our dataset in the form of a CSV file: Cricketers2.csvAt first, import the required libraries −import seaborn as sb import pandas as pd import matplotlib.pyplot as pltLoad data from a CSV file into a Pandas DataFrame −dataFrame = pd.read_csv("C:\Users\amit_\Desktop\Cricketers2.csv") Group the swarms by two categorical variables −sb.swarmplot(x = "Role", y = "Matches", hue = "Academy", ... Read More
422 Views
Violin Plot in Seaborn is used to draw a combination of boxplot and kernel density estimate. The seaborn.violinplot() is used for this. Set explicit order using the order parameter of the violinplot().Let’s say the following is our dataset in the form of a CSV file − Cricketers.csvAt first, import the required libraries −import seaborn as sb import pandas as pd import matplotlib.pyplot as pltLoad data from a CSV file into a Pandas DataFrame −dataFrame = pd.read_csv("C:\Users\amit_\Desktop\Cricketers.csv") Plotting violin plot with Role and Age. Control order by passing an explicit order i.e. ordering on the basis of "Role".sb.violinplot(x = 'Role', y ... Read More
12K+ Views
To read all excel files in a directory, use the Glob module and the read_excel() method.Let’s say the following are our excel files in a directory −Sales1.xlsxSales2.xlsxAt first, set the path where all the excel files are located. Get the excel files and read them using glob −path = "C:\Users\amit_\Desktop\" filenames = glob.glob(path + "\*.xlsx") print('File names:', filenames)Next, use the for loop to iterate and read all the excels files in a specific directory. We are also using read_excel() −for file in filenames: print("Reading file = ", file) print(pd.read_excel(file))ExampleFollowing is the complete code ... Read More
2K+ Views
To merge more than one CSV files into a single Pandas dataframe, use read_csv. At first, import the required Pandas library. Here. We have set pd as an alias −import pandas as pdNow, let’s say the following are our CSV Files −Sales1.csvSales2.csvWe have set the path as string. Both the files are on the Desktop −file1 = "C:\Users\amit_\Desktop\sales1.csv" file2 = "C:\Users\amit_\Desktop\sales2.csv"Next, merge the above two CSV files. The pd.concat() merge the CSV files together −dataFrame = pd.concat( map(pd.read_csv, [file1, file2]), ignore_index=True)ExampleFollowing is the code −import pandas as pd file1 = "C:\Users\amit_\Desktop\sales1.csv" file2 = "C:\Users\amit_\Desktop\sales2.csv" print("Merging ... Read More
836 Views
If you ever used C + +, then you must have heard about Palindrome numbers. So in this guide, we will explain everything about "Nth even-length Palindrome" using appropriate examples. Palindrome numbers are numbers that stay the same after reversing them. Not only numbers but a word whose spelling stays the same when its characters are reversed. For Example −Numbers = {1, 121, 131, 656, 1221, 1551}Words = {saas, malayalam, level, mom}It looks complicated but very easy to perform on any system. So let's discuss the palindrome in brief.Nth Even length Palindrome Number11, 22, 33, 44, 55, 66, 77, 88, ... Read More
1K+ Views
In this article, we will explore how to concatenate more than two pandas DataFrames using the pandas and numpy modules. Typically, the pandas.concat() method is used to concatenate multiple data frames. This method allows for concatenation along rows (axis=0) or columns (axis=1), providing flexibility in combining data efficiently. A DataFrame in Python's pandas library is a two-dimensional labeled data structure that is used for data manipulation and analysis. It can handle different data types such as integers, floats, and strings. Each column has a unique label, and each row is labeled with a unique index value, which helps in ... Read More
2K+ Views
To stack a multi-level column, use the stack() method. At first, import the required library −import pandas as pdCreate a multi-level column −items = pd.MultiIndex.from_tuples([('Maths', 'Mental Maths'), ('Maths', 'Discrete Mathematics'), ('Maths', 'Applied Mathematics')]) Now, create a DataFrame and set multi-level columns we set above −dataFrame = pd.DataFrame([[67, 86, 78], [56, 92, 97], [92, 95, 91]], index=['John', 'Tom', 'Henry'], columns=items)Stack the multi-level column −dataframe.stack()ExampleFollowing is the complete code −import pandas as pd # multi-level columns items = pd.MultiIndex.from_tuples([('Maths', 'Mental Maths'), ('Maths', 'Discrete Mathematics'), ('Maths', 'Applied Mathematics')]) # creating a DataFrame dataFrame = pd.DataFrame([[67, 86, 78], [56, 92, 97], ... Read More
1K+ Views
To create a subset and display only the last entry from duplicate values, use the “keep” parameter with the ‘last” value in drop_duplicates() method. The drop_duplicates() method removed duplicates.Let us 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': [85, 70, 80, 95, 55, 90]})Removing duplicates and displaying last entry. Using keep parameter, we have set "last". Duplicate rows except the last entry will get deleted. We have considered a subset using the “subset” parameter −dataFrame2 = dataFrame.drop_duplicates(subset = ['Car', 'Place'], keep ='last').reset_index(drop = True)ExampleFollowing ... Read More