Rishikesh Kumar Rishi has Published 1162 Articles

How to get the row count of a Pandas DataFrame?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 30-Aug-2021 09:22:48

411 Views

To get the row count of a Pandas DataFrame, we can use the length of DataFrame index.StepsCreate a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.Print the input DataFrame.Print the length of the DataFrame index list, len(df.index).Example Live Demoimport pandas as pd df = pd.DataFrame(    {       "x": ... Read More

Select multiple columns in a Pandas DataFrame

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 30-Aug-2021 09:20:35

2K+ Views

To select multiple columns in a Pandas DataFrame, we can create new a DataFrame from the existing DataFrameStepsCreate a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.Print the input DataFrame.Create a new DataFrame, df1, with selection of multiple columns.Print the new DataFrame with multiple selected columns.Example Live Demoimport pandas as pd ... Read More

How to rename column names in a Pandas DataFrame?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

301 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

745 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

285 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

3K+ 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

1K+ 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

230 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

7K+ 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

Advertisements