Using Series (Row-Wise)
import pandas as pd purchase_1 = pd.Series({‘Name‘: ‘Chris‘, ‘Item Purchased‘: ‘Dog Food‘, ‘Cost‘: 22.50}) purchase_2 = pd.Series({‘Name‘: ‘Kevyn‘, ‘Item Purchased‘: ‘Kitty Litter‘, ‘Cost‘: 2.50}) purchase_3 = pd.Series({‘Name‘: ‘Vinod‘, ‘Item Purchased‘: ‘Bird Seed‘, ‘Cost‘: 5.00}) df = pd.DataFrame([purchase_1, purchase_2, purchase_3], index=[‘Store 1‘, ‘Store 1‘, ‘Store 2‘]) df.head()
原文地址:https://www.cnblogs.com/sherrydatascience/p/10336571.html
时间: 2024-10-27 10:18:25