/simple-data-analysis

The Simple Guide to Data Analysis.

MIT LicenseMIT

The Simple Guide to Data Analysis with Python

Data Analysis with Python explained simply.

GitHub license PRs Welcome

Table of Contents

What is Data Analysis?

What does Data Analysis look like?

How do I get the last n rows of a DataFrame?

df.tail(10)

How do I get the rows of a DataFrame starting from row i to j?

df.iloc[i:j]

How do I add multiple columns to a DataFrame simultaneously?

df.assign(
    **{
        'newcol_1': 'some default',
        'newcol_2': 'some default',
        'newcol_3': 'some default',
    }
)

Create the dict above programmatically.

How do I create a 1d array?

np.array([1,2,3,4,5])
np.arange(0,10)

How do I create a 2d array?

np.array([1,2,3,4,5],[6,7,8,9,10])
np.arange(0,10)

How do I create a 1d array of random numbers from 0 to 1?

np.random.rand(10)  # generates a 1d array of 10 elements

How do I perform operations on all the values of an array?

arr + 5
arr - 5
arr * 5
arr / 5

How do I get the nth column or row of data in an array?

arr[0, :]  # first column
arr[:, 0]  # first row