Category: Python
Upload CSV to Github
This tutorial shows how can you upload CSV file to Github. It includes detailed steps and examples. Step 1: Create a new repository A new repository is where CSV files will be stored. Below. I created one and name it...
Read Full Article →
Pandas: Select Two Columns from a Dataframe (Examples)
There are at least 3 methods to select 2 or more than 2 columns from a dataframe in Python. Method 1: Use a list of column names df[ [ "col1", "col2" ] ] Method 2: Use a range of column...
Read Full Article →
Use sklearn for Linear Regression in Python
Introduction We can use sklearn.linear_model.LinearRegression to do linear regression in Python. The following is the core syntax of using sklearn. lm.fit(IVs, DV) Where, IVs: the independent variables DV: the dependent variable Example for Linear Regression Model The following is the...
Read Full Article →
Pandas: Read All Sheets in Excel
This tutorial shows how you can read multiple sheets in Excel in Python. The following shows the two major steps. Step 1: Read all sheets as a dictionary You can read all sheets in Excel altogether using the parameter of...
Read Full Article →
How to Convert Index as Column in Pandas
This tutorial shows how you can convert dataframe index as a column in Python. The basic syntax is to use reset_index() (see below). df_name.reset_index() Starting Dataframe for Examples 1 and 2 The following is the sample dataframe that will be...
Read Full Article →
How to Clear or Empty a List in Python (Examples)
This tutorial shows 2 methods to clear a list in Python using examples. Method 1: Use clear() to empty a list You can use the method of clear() to empty a list in Python. The following is an example. ['Tesla',...
Read Full Article →
How to Plot a Single Point in Matplotlib Python
You can use plt.plot() to plot a sinple point on an existing plot in Python Matplotlib. Method 1: Just a single point on the plot The following plot a point of (-3, 1) in a plot using Matplotlib in Python....
Read Full Article →
How to Read Excel with Multiple Sheets with Pandas (Python)
This tutorial shows how you can use read_excel() read Excel files with multiple sheets. The following is the illustration for sheet1 and sheet2. They have the same data structure, but in 2 different sheets. You can download the Excel file...
Read Full Article →
What is the difference between `sep` and `delimiter` attributes in read_csv() and read_table() in Pandas
This tutorial explains the difference between sep and delimiter in read_csv() and read_table() in Pandas. In short, `sep` and `delimiter` are the same in both read_csv() and read_table() functions in Pandas. You can use either one of them. In both...
Read Full Article →
How to Read Text (txt) Files in Pandas
This tutorial uses example Python codes to show 2 methods to read a text (txt) file into the Python programming environment. The following is the screenshot of the txt file. Method 1: Use read_csv() function to read txt You can...
Read Full Article →