How to Create Pandas Series from a List

You can create Pandas Series from a list using this syntax: Copy pd.Series(list_name) Steps to Create Pandas Series from a List Step 1: Create a List To start, let’s create a list that contains 5 names: Copy people_list = [‘Jon’, ‘Mark’, ‘Maria’, ‘Jill’, ‘Jack’] print(people_list) This is how the list would look like: The ultimate … Read more

Replace Values in Pandas DataFrame

Here are 4 ways to replace values in Pandas DataFrame: (1) Replace a single value with a new value: Copy df[“column_name”] = df[“column_name”].replace([“old_value”], “new_value”) (2) Replace multiple values with a new value: Copy df[“column_name”] = df[“column_name”].replace([“1st_old_value”, “2nd_old_value”, …], “new_value”) (3) Replace multiple values with multiple new values: Copy df[“column_name”] = df[“column_name”].replace([“1st_old_value”, “2nd_old_value”, …], [“1st_new_value”, “2nd_new_value”, … Read more

How to Download and Install Julia on Windows

In this short guide, you’ll see how to download and install Julia from scratch. You’ll also see how to run a simple code in Julia. Here are the steps that you may follow. Steps to Download and Install Julia on Windows Step 1: Download Julia To begin, go to julialang.org/downloads and then click on the … Read more

Measure the Time it Takes to Run a Python Script

To measure the time it takes to run a Python script: Copy import timestart_time = time.time()# Place your python script hereexecution_time = time.time() – start_timeprint(“Execution time in seconds: ” + str(execution_time)) Steps to Measure the Time it Takes to Run a Python Script Step 1: Write the Python Script For illustration purposes, let’s write a Python … Read more

How to Change the Pandas Version in Windows

You can change the Pandas version in Windows using this command: Copy pip install pandas==pandas version needed –user For example, if the Pandas version needed is 1.1.1, then open the Windows Command Prompt and type/copy the command below: Copy pip install pandas==1.1.1 –user Note that the above method would work only if you added Python … Read more

3 Ways to Create NaN Values in Pandas DataFrame

In this article, you’ll see 3 ways to create NaN values in Pandas DataFrame: 3 Ways to Create NaN Values in Pandas DataFrame (1) Using Numpy You can easily create NaN values in Pandas DataFrame using Numpy. More specifically, you can place np.nan each time you want to add a NaN value in the DataFrame. … Read more

Check the Data Type of each DataFrame Column in R

Here are 2 ways to check the data type of each DataFrame column in R: (1) Using str(): Copy str(df) (2) Using sapply() and class(): Copy sapply(df, class) Next, you’ll see a simple example with the steps to: Steps to Check the Data Type of each DataFrame Column in R Step 1: Create a DataFrame … Read more

Categories R

How to Run One Python Script From Another

In this short guide, you’ll see how to run one Python script from another Python script. Steps Step 1: Place the Python Scripts in the Same Folder To start, place your Python scripts in the same folder. For example, assume that two Python scripts (called python_1 and python_2) are stored in the same folder: python_1python_2 … Read more

3 Simple Examples of For Loop in Python

In this short post, you’ll see 3 simple examples of For Loop in Python: 3 Examples Example 1: Looping over a List Suppose that you created a list of integers: Copy my_list = [22, 57, 15, 8, 29] To increase each value in the list by 1 using a For Loop: Copy my_list = [22, … Read more

Plot a Line Chart in Python using Matplotlib

In this short guide, you’ll see how to plot a Line chart in Python using Matplotlib. To start, here is a template that you may use to plot your Line chart: Copy import matplotlib.pyplot as pltx_axis = [“value_1”, “value_2”, “value_3”, …]y_axis = [“value_1”, “value_2”, “value_3”, …]plt.plot(x_axis, y_axis)plt.title(“title name”)plt.xlabel(“x_axis name”)plt.ylabel(“y_axis name”)plt.show() Next, you’ll see how to … Read more