Python

How to Convert Floats to Strings in Pandas DataFrame

In this short guide, you’ll see 3 approaches to convert floats to strings in Pandas DataFrame for: (1) An individual DataFrame column using astype(str): df[‘DataFrame Column’] = df[‘DataFrame Column’].astype(str) (2) An individual DataFrame column using apply(str): df[‘DataFrame Column’] = df[‘DataFrame Column’].apply(str) (3) An entire DataFrame using: df = df.astype(str) Next, you’ll see how to apply …

How to Convert Floats to Strings in Pandas DataFrame Read More »

How to Convert Floats to Integers in Pandas DataFrame

You can convert floats to integers in Pandas DataFrame using: (1) astype(int): df[‘DataFrame Column’] = df[‘DataFrame Column’].astype(int) (2) apply(int): df[‘DataFrame Column’] = df[‘DataFrame Column’].apply(int) In this guide, you’ll see 4 scenarios of converting floats to integers for: Specific DataFrame column using astype(int) or apply(int) Entire DataFrame where the data type of all columns is float …

How to Convert Floats to Integers in Pandas DataFrame Read More »

How to Create a Horizontal Bar Chart using Matplotlib

Here is a simple template that you can use to create a horizontal bar chart using Matplotlib: import matplotlib.pyplot as plt y_axis = [‘Item 1’, ‘Item 2’, ‘Item 3’, …] x_axis = [‘Item 1’, ‘Item 2’, ‘Item 3’, …] plt.barh(y_axis,x_axis) plt.title(‘title name’) plt.ylabel(‘y axis name’) plt.xlabel(‘x axis name’) plt.show() Later, you’ll also see how to …

How to Create a Horizontal Bar Chart using Matplotlib Read More »