Rishikesh Kumar Rishi has Published 1162 Articles

How to add a 3d subplot to a matplotlib figure?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 20-Sep-2021 09:09:37

3K+ Views

To add a 3D subplot to a matplotlib figure, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create x, y and z data points using numpy.Create a new figure or activate an existing figure.Add an 'ax' to the figure as ... Read More

How to set labels in matplotlib.hlines?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 19-Sep-2021 08:10:07

4K+ Views

To set labels in matplotlib.hlines, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Add a horizontal line across the axis, y=1, with y=1 label, color='orange'.Add a horizontal line across the axis, y=2, with y=2 label, color='red'.To display the figure, use ... Read More

How to make a scatter plot for clustering in Python?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 19-Sep-2021 08:00:50

6K+ Views

To make a scatter plot for clustering in Python, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create x and y data points, Cluster and centers using numpy.Create a new figure or activate an existing figure.Add a subplot arrangement to ... Read More

How do I put a circle with annotation in matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 19-Sep-2021 07:28:03

2K+ Views

To put a circle with annotation in matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create data points using numpy.Get the point coordinate to put circle with annotation.Get the current axis.Plot the data and data points using plot() method.Set ... Read More

How to make a 3D scatter plot in Python?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 19-Sep-2021 07:08:45

2K+ Views

To get a 3D plot, we can use fig.add_subplot(111, projection='3d') method to instantiate the axis. After that, we can use the scatter method to draw different data points on the x, y, and z axes.StepsCreate a new figure, or activate an existing figure.Add an `~.axes.Axes` to the figure as part of ... Read More

How to shift a column in a Pandas DataFrame?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Sep-2021 07:23:13

8K+ Views

We can use the shift() method in Pandas to shift the columns of a DataFrame without having to rewrite the whole DataFrame. shift() takes the following parametersshift(self, periods=1, freq=None, axis=0, fill_value=None)periods  Number of periods to shift. It can take a negative number too.axis  It takes a Boolean value; 0 if ... Read More

How to find numeric columns in Pandas?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Sep-2021 06:52:03

6K+ Views

To find numeric columns in Pandas, we can make a list of integers and then include it into select_dtypes() method. Let's take an example and see how to apply this method.StepsCreate a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.Print the input DataFrame, df.Make a list of data type, i.e., numerics, ... Read More

How to filter rows in Pandas by regex?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 14-Sep-2021 13:51:18

16K+ Views

A regular expression (regex) is a sequence of characters that define a search pattern. To filter rows in Pandas by regex, we can use the str.match() method.StepsCreate a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.Print the input DataFrame, df.Initialize a variable regex for the expression. Supply a string value as ... Read More

Python – Pandas Dataframe.rename()

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 14-Sep-2021 13:40:06

4K+ Views

It's quite simple to rename a DataFrame column name in Pandas. All that you need to do is to use the rename() method and pass the column name that you want to change and the new column name. Let's take an example and see how it's done.StepsCreate a two-dimensional, size-mutable, ... Read More

How to access a group of rows in a Pandas DataFrame?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 14-Sep-2021 13:35:39

3K+ Views

To access a group of rows in a Pandas DataFrame, we can use the loc() method. For example, if we use df.loc[2:5], then it will select all the rows from 2 to 5.StepsCreate a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.Print the input DataFrame, df.Use df.loc[2:5] to select the rows ... Read More

Advertisements