Source Code:
(back to article)
import numpy as np import pandas as pd # Numpy array data = np.array([[1, 2, 3], [4, 5, 6]]) # Index column index = ['row1', 'row2'] # Column headers columns = ['col 1', 'col2', 'col3'] # Create DataFrame df = pd.DataFrame(data, index=index, columns=columns)
Result:
Report an issue