
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 26504 Articles for Server Side Programming

2K+ Views
In this program, we will find the index position at which a multiple of a given number exists. We will use both the Numpy and the Pandas library for this task.AlgorithmStep 1: Define a Pandas series. Step 2: Input a number n from the user. Step 3: Find the multiples of that number from the series using argwhere() function in the numpy library.Example Codeimport numpy as np listnum = np.arange(1, 20) multiples = [] print("NumList:", listnum) n = int(input("Enter the number you want to find multiples of: ")) for num in listnum: if num % n == ... Read More

487 Views
In this program, we will calculate the frequency of each element in a Pandas series. The function value_counts() in the pandas library helps us to find the frequency of elements.AlgorithmStep 1: Define a Pandas series. Step 2: Print the frequency of each item using the value_counts() function.Example Codeimport pandas as pd series = pd.Series([10,10,20,30,40,30,50,10,60,50,50]) print("Series:", series) frequency = series.value_counts() print("Frequency of elements:", frequency)OutputSeries: 0 10 1 10 2 20 3 30 4 40 5 30 6 50 7 10 8 60 9 50 10 50 dtype: int64 Frequency of elements: 50 3 10 3 30 2 20 1 40 1 60 1 dtype: int64

1K+ Views
A percentile is a term used in statistics to express how a score compares to other scores in the same set. In this program, we have to find nth percentile of a Pandas series.AlgorithmStep 1: Define a Pandas series. Step 2: Input percentile value. Step 3: Calculate the percentile. Step 4: Print the percentile.Example Codeimport pandas as pd series = pd.Series([10, 20, 30, 40, 50]) print("Series:", series) n = int(input("Enter the percentile you want to calculate: ")) n = n/100 percentile = series.quantile(n) print("The {} percentile of the given series is: {}".format(n*100, percentile))OutputSeries: 0 10 1 ... Read More

5K+ Views
Subplot can split the figure in nrow*ncols parts and plt.xticks could help to plot the xticks for subplots.StepsCreate two lists for line 1 and line 2.Add a subplot to the current figure, nrow = 1, ncols = 2 and index = 1.Draw line 1 with style as dashed.Set or retrieve auto scaling margins(0.2).Place xticks at even places.Set a title for the X-axis.Add a subplot to the current figure, nrow = 1, ncols = 2 and index = 2.Plot line 2.Set or retrieve auto scaling margins(0.2).Place xticks at odd places.Set a title for the X-axis.To show the figure use plt.show() method.Exampleimport ... Read More

9K+ Views
We will create two lines, i.e., line1 and line2. After that, we will pop the second line and will remove it.StepsCreate lists for line1 and line2.Plot line1 and line 2 using plot() method, line 2 with style =’dashed’.Set or retrieve auto-scaling margins(0.2).Pop line 2, and remove it using remove() method.The final figure will have only one line, so use plt.show() method.Exampleimport matplotlib.pyplot as plt line1 = [2, 4, 8] line2 = [3, 6, 12] plt.plot(line1) line_2 = plt.plot(line2, linestyle='dashed') plt.margins(0.2) plt.title("With extra lines") plt.show() plt.plot(line1) l = line_2.pop(0) l.remove() plt.margins(0.2) plt.title("Removed extra lines") plt.show()Input Diagram (Before ... Read More

2K+ Views
We can create a dict for color and a value. If the same value comes up, we can use a scatter method and if the closer values have the same set of colors, that could make the plot color denser.StepsCreate a new figure, or activate an existing figure.Add an ~.axes.Axes to the figure as part of a subplot arrangement.Get the x and y values using np.random.normal() method. Draw random samples from a normal (Gaussian) distribution.Make a color list with red and blue colors.To make it denser, we can store the same color with the same value.Plot scatter point, a scatter ... Read More

3K+ Views
In this program, we will compare two Pandas series and will print the differences in the series. By difference, we mean that the index positions at which the elements did not match.AlgorithmStep 1: Define two Pandas series, s1 and s2. Step 2: Compare the series using compare() function in the Pandas series. Step 3: Print their difference.Example Codeimport pandas as pd s1 = pd.Series([10, 20, 30, 40, 50, 60]) s2 = pd.Series([10, 30, 30, 40, 55, 60]) print("S1:", s1) print("S2:", s2) difference = s1.compare(s2) print("Difference between the series: ", difference)OutputS1: 0 10 1 20 2 ... Read More

376 Views
In this program, we will find the standard deviation of a Pandas series. Standard deviation is a statistic that measures the dispersion of a dataset relative to its mean and is calculated as the square root of the variance.AlgorithmStep 1: Define a Pandas series Step 2: Calculate the standard deviation of the series using the std() function in the pandas library. Step 3: Print the standard deviation.Example Codeimport pandas as pd series = pd.Series([10,20,30,40,50]) print("Series: ", series) series_std = series.std() print("Standard Deviation of the series: ",series.std())OutputSeries: 0 10 1 20 2 30 3 40 4 50 dtype: int64 Standard Deviation of the series: 15.811388300841896

1K+ Views
mean() function in the Pandas library can be used to find the mean of a series.AlgorithmStep 1: Define a Pandas series. Step 2: Use the mean() function to calculate the mean. Step 3: Print the mean.Example Codeimport pandas as pd series = pd.Series([10,20,30,40,50]) print("Pandas Series: ", series) series_mean = series.mean() print("Mean of the Pandas series:", series_mean)OutputPandas Series: 0 10 1 20 2 30 3 40 4 50 dtype: int64 Mean of the Pandas series: 30.0

10K+ Views
The correlation matrix with p-values for an R data frame can be found by using the function rcorr of Hmisc package and read the output as matrix. For example, if we have a data frame called df then the correlation matrix with p-values can be found by using rcorr(as.matrix(df)).ExampleConsider the below data frame − Live Demodf1