Rishikesh Kumar Rishi has Published 1156 Articles

How to rename column names in a Pandas DataFrame?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 30-Aug-2021 09:15:30

420 Views

To rename columns in a Pandas DataFrame, we can override df.columns with the new column names.StepsCreate a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.Print the input DataFrame.Override the columns with new list of column names.Print the DataFrame again with the renamed column names.Example Live Demoimport pandas as pd df = ... Read More

Select rows from a Pandas DataFrame based on column values

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 30-Aug-2021 09:13:15

910 Views

To select rows from a DataFrame based on column values, we can take the following Steps −Create a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.Print the input DataFrame.Use df.loc[df["x"]==2] to print the DataFrame when x==2.Similarly, print the DataFrame when (x >= 2) and (x < 2).Example Live Demoimport pandas as pd ... Read More

How to iterate over rows in a DataFrame in Pandas?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 30-Aug-2021 06:54:29

354 Views

To iterate rows in a DataFrame in Pandas, we can use the iterrows() method, which will iterate over DataFrame rows as (index, Series) pairs.StepsCreate a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.Iterate df using df.iterrows() method.Print each row with index.Example Live Demoimport pandas as pd df = pd.DataFrame(    { ... Read More

How to properly enable ffmpeg for matplotlib.animation?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 10-Aug-2021 09:20:01

4K+ Views

To enable ffmpeg for matplotlib.animation, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Set the ffmpeg directory.Create a new figure or activate an existing figure, using figure() method.Add an 'ax1' to the figure as part of a subplot arrangement.Plot the ... Read More

How to make multipartite graphs using networkx and Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 10-Aug-2021 07:20:47

2K+ Views

To make multipartite graph in networkx, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a list of subset sizes and colors.Define a method for multilayered graph that could return a multilayered graph object.Set the color of the nodes.Position the ... Read More

How to plot the difference of two distributions in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 10-Aug-2021 07:19:23

2K+ Views

To plot the difference of two distributions in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a and b datasets using Numpy.Get kdea and kdeb, i.e., representation of a kernel-density estimate using Gaussian kernels.Create a grid using Numpy.Plot ... Read More

What exactly is a Matplotlib axes object?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 10-Aug-2021 07:18:18

368 Views

The Axes class contains most of the figure elements − Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system.stepsSet the figure size and adjust the padding between and around the subplots.Set the axes linewidth using rcParams.Add an axes to the current figure and make it the current axes.Set ... Read More

How to visualize 95% confidence interval in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 10-Aug-2021 07:16:53

8K+ Views

To visualize 95% confidence interval in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create x and y data sets.Get the confidence interval dataset.Plot the x and y data points using plot() method.Fill the area within the confidence interval ... Read More

Plotting an imshow() image in 3d in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 10-Aug-2021 07:15:44

5K+ Views

To plot an imshow() image in 3D in Matplotlib, we can take the following steps −Create xx and yy data points using numpy.Get the data (2D) using X, Y and Z.Create a new figure or activate an existing figure using figure() method.Add an 'ax1' to the figure as part of ... Read More

Adding extra contour lines using Matplotlib 2D contour plotting

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 10-Aug-2021 07:13:35

1K+ Views

To add extra contour lines using Matplotlib 2D contour plotting, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create e a function f(x, y) to get the z data points from x and y.Create x and y data points using ... Read More

Advertisements