Paired t-test in R (2 Examples)

Method 1 for paired t-test is for a situation group 1 and group 2 are two separate vectors, whereas Method 2 is for two groups of data in the same column. Method 1: t.test(group_1, group_2, paired = TRUE) Method 2: t.test(y~group, data=my_data, paired = TRUE) Data and Hypothesis Suppose we would like to test whether … Read more

Categories R

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 index df.iloc [ : , 0 : 2 ] Method 3: Use specific column indexes … Read more

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 sheet_name=None in pd.read_excel(). Without this, it will only read the first sheet, by default. The … Read more

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 used in Examples 1 and 2. (Note that, Example 3 will use a different dataframe.) … Read more

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’, ‘Ford’, ‘Toyota’] [] Method 2: Use Del to clear or empty a list You can … Read more

Two sample t-test: Definition, formula, and Examples

Two sample t-test is also called independent sample t-test or unpaired sample t-test. This tutorial explains what two sample t-test is, its formula, and examples of two sample t-test. Definition and Example Two sample t-test is used to test whether means from two different groups of people or objects are significantly different. The name of … Read more

Pandas: Read CSV from Github

Step 1: Hit “Raw” button You go to the Github page and find the csv file page. For instance, you can click this link for one. Then, you click Raw. Step 2: Copy the raw link and paste into the read_csv() Next, you copy the link and paste it within the function of read_csv() from … Read more

How to Read CSV or Excel Files in Pandas

This tutorial shows how you can read CSV or Excel files into Pandas in Python. To do that, you can import Pandas and then use its function of read_csv() to read csv files in Python. The following is the Python code to read the CSV file into Python using Pandas. The following shows the print … Read more

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 from Github by clicking this link. Method 1: Just read the first sheet Use read_excel() … Read more

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 function description, you can see the following statement. delimiterstr, default None Alias for sep. Brand … Read more