Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

DataFrames Basics

Import libs

First let’s import both pandas and numpy.

import pandas as pd
import numpy as np

The read_csv method will read in a CSV file and returns to us a DataFrame

One dimention array

sr = pd.Series([1, 3, 5, np.nan, 6, 8])
sr
0 1.0 1 3.0 2 5.0 3 NaN 4 6.0 5 8.0 dtype: float64
type(sr)
pandas.core.series.Series
sr.describe()
count 5.000000 mean 4.600000 std 2.701851 min 1.000000 25% 3.000000 50% 5.000000 75% 6.000000 max 8.000000 dtype: float64
sr.to_numpy()
array([ 1., 3., 5., nan, 6., 8.])

Two dimention array

dates = pd.date_range("20130101", periods=6)
dates
DatetimeIndex(['2013-01-01', '2013-01-02', '2013-01-03', '2013-01-04', '2013-01-05', '2013-01-06'], dtype='datetime64[ns]', freq='D')

Read more from here