Making DataFrames

Provide a list or numpy array

The column and row labels will simply use the numerical index

import pandas as pd
import numpy as np
z = np.array([[1,2,3,4,5],[6,7,8,9,10]])
z

[['a', 'b', 'c'], [10, 5, 2.5], [3, 2, 1]]

(3, 3)

Provide a dictionary

(2, 3)

Index(['a', 'b', 'c'], dtype='object')

Index(['row1', 'row2'], dtype='object')

Read a CSV file

Read an Excel file

Last updated

Was this helpful?