码迷,mamicode.com
首页 > 编程语言 > 详细

[Python Cookbook] Pandas: 3 Ways to define a DataFrame

时间:2019-01-30 07:28:06      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:ase   panda   dog   purchase   head   frame   foo   code   seed   

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()

 

[Python Cookbook] Pandas: 3 Ways to define a DataFrame

标签:ase   panda   dog   purchase   head   frame   foo   code   seed   

原文地址:https://www.cnblogs.com/sherrydatascience/p/10336571.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!