python python_dataframes_csv.py

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python python_dataframes_csv.py相关的知识,希望对你有一定的参考价值。

import pandas as pd

orders = pd.read_csv('/Users/itversity/Research/data/retail_db/orders/part-00000', 
            names=['order_id', 'order_date', 'order_customer_id', 'order_status'],
            index_col='order_id')
orders.groupby(['order_status'])['order_status'].count()

order_items = pd.read_csv('/Users/itversity/Research/data/retail_db/order_items/part-00000', 
            names=['order_item_id', 'order_item_order_id', 'order_item_product_id',
                   'order_item_quantity', 'order_item_subtotal', 'order_item_product_price'],
            index_col='order_item_order_id')

ordersCompleted = orders.loc[(orders['order_status'] == 'COMPLETE') | (orders['order_status'] == 'CLOSED')]
ordersCompleted.join(order_items).groupby(['order_date'])['order_item_subtotal'].sum()

以上是关于python python_dataframes_csv.py的主要内容,如果未能解决你的问题,请参考以下文章

python中__call__方法解析

python中的__name__

求一道python编程题

Python __name__ == ‘__main__’详细解释-Python零基础入门教程

Python __dict__与dir()区别

Python零碎