#coding=utf-8

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker # ------------ 设置为系统中的中文字体------------
from pylab import *
mpl.rcParams['font.sans-serif'] = ['SimHei'] # linux下中文乱码处理
mpl.rcParams['font.sans-serif'] = ['Microsoft YaHei'] # windows下中文乱码处理 # plot 线形图
# bar 条形图
# scatter 点状图
# stackplot 堆叠图
CONST_FIGURE_TYPE = 'plot' def read_csv():
filename = "E:/work/work_git/python_personalrepo/data/order_statis_2.csv"
# filename = 'e:\\order_statis_2.csv'
df = pd.read_csv(filename)
# print df.head()
return df # 格式化日期
def format_date(x, pos=None):
thisindex = np.clip(int(x + 0.5), 0, len(df) - 1)
datetime_ret = df['days'][thisindex]
return datetime_ret # 构建数据
def build_data_ordercount():
x_axis_values = []
y_axis_values = [] # print df['days']
for index, row in df.iterrows():
x_axis_values.append(index)
y_axis_values.append(row['count']) x_axis_values = np.arange(len(df))
# print x_axis_values
# print y_axis_values fig,ax = plt.subplots() ax.plot(x_axis_values, y_axis_values, 'o-',label=u'订单数量')
# x轴标签 倾斜角度
# plt.xticks(rotation=30) ax.xaxis.set_major_formatter(ticker.FuncFormatter(format_date))
fig.autofmt_xdate() return False # 构建数据
def build_data_ordermoney():
x_axis_values1 = []
y_axis_values1 = [] for index, row in df.iterrows():
x_axis_values1.append(index + 1)
y_axis_values1.append(row['money']/1000.0) # print x_axis_values1
# print y_axis_values1 plt.plot(
# X 轴
x_axis_values1,
# y轴
y_axis_values1, 'ro-', label=u'订单金额') return False # 绘制图形
def show_figure():
plt.ylabel(u'订单数量')
plt.xlabel(u'下单日期')
plt.title(u'订单走势')
plt.legend() plt.show() return False if __name__ == "__main__":
df = read_csv()
# print df.head()
build_data_ordercount()
build_data_ordermoney()
show_figure()

  

python统计订单走势的更多相关文章

  1. python统计元素重复次数

    python统计元素重复次数 # !/usr/bin/python3.4 # -*- coding: utf-8 -*- from collections import Counter arr = [ ...

  2. 简易安装python统计包

    PythonCharm简易安装python统计包及 本文介绍使用pythonCharm IDE 来安装Python统计包或一些packages的简单过程,基本无任何技术难度,顺便提一提笔者在安装过程中 ...

  3. Python统计列表中的重复项出现的次数的方法

    本文实例展示了Python统计列表中的重复项出现的次数的方法,是一个很实用的功能,适合Python初学者学习借鉴.具体方法如下:对一个列表,比如[1,2,2,2,2,3,3,3,4,4,4,4],现在 ...

  4. Python统计日志中每个IP出现次数

    介绍了Python统计日志中每个IP出现次数的方法,实例分析了Python基于正则表达式解析日志文件的相关技巧,需要的朋友可以参考下 本脚本可用于多种日志类型 #-*- coding:utf-8 -* ...

  5. python 统计时间,写日志

    python 统计时间使用time模块,写日志使用logging模块,这两个都是标准模板. 测试socket使用socket模块 # 统计时间 ---------------------- impor ...

  6. python统计文本中每个单词出现的次数

    .python统计文本中每个单词出现的次数: #coding=utf-8 __author__ = 'zcg' import collections import os with open('abc. ...

  7. python统计文档中词频

    python统计文档中词频的小程序 python版本2.7 效果如下: 程序如下,测试文件与完整程序在我的github中 #统计空格数与单词数 本函数只返回了空格数 需要的可以自己返回多个值 def ...

  8. python统计字符串里每个字符的次数

    方法一: 推导式 dd="ewq4aewtaSDDSFDTFDSWQrtewtyufashas" print {i:dd.count(i) for i in dd} 方法二: co ...

  9. python 统计使用技巧

    python 统计使用技巧 # 1.不输入回车获取值 注:需要tty模块配合. fd = sys.stdin.fileno() old_settings = termios.tcgetattr(fd) ...

随机推荐

  1. 【bzoj1486】【[HNOI2009]梦幻布丁】启发式链表合并(详解)

    (画师当然是武内崇啦) Description N个布丁摆成一行,进行M次操作.每次将某个颜色的布丁全部变成另一种颜色的,然后再询问当前一共有多少段颜色.例如颜色分别为1,2,2,1的四个布丁一共有3 ...

  2. linux内核3.6版本及以下的bug引发的故障--cpu使用率100%

    现象:         旗舰店运价库cpu使用率100%,load升高,导致后续的请求失败.         重启服务器,cpu.load恢复正常. 触发条件:        (1)linux内核3. ...

  3. 谁说 JavaScript 很简单了?

    转载请注明出处,保留原文链接以及作者信息 本文介绍了 JavaScript 初学者应该知道的一些技巧和陷阱.如果你是老司机,就当做回顾了,哪里有写的不好的地方欢迎指出. 1. 你是否尝试过对一个数字数 ...

  4. Android 友盟社会化组件-分享实现

    本文章链接地址:http://dev.umeng.com/social/android/share/quick-integration 分享快速集成 1 产品概述 友盟社会化组件,可以让移动应用快速具 ...

  5. [Android 4.4.4] 泛泰A850 三版通刷 Mokee4.4.4 KTU84P 20140626 RC2.2 by syhost

    RC2.1版地址: http://blog.csdn.net/syhost/article/details/34051923 2014.06.26 RC2.2 更新内容: 1 修复相机录像无声的bug ...

  6. [转载]DIY树莓派之随身工具箱

    摆弄树莓派有一年多了,在这里把经验分享给大家,少走弯路. 先放图两张. 搭建目的: wifi信号中转站\网站服务器\IC卡渗透测试\中间人\otr… 基于树莓派3 系统为Kali Linux 2017 ...

  7. 各种分布 高斯 Gamma Beta 多项分布

  8. 【AS3 Coder】任务八:没剧情还玩毛RPG

    使用框架:AS3任务描述:了解RPG游戏中剧情播放器的制作原理及流程难度系数:3(了解原理,能根据XML文件播放剧情) / 5(会制作剧情编辑器) 本章源码下载:http://www.iamseven ...

  9. [Javascript] Write a Generator Function to Generate the Alphabet / Numbers

    When you need to generate a data set, a generator function is often the correct solution. A generato ...

  10. python对象序列化或持久化的方法

    http://blog.csdn.net/chen_lovelotus/article/details/7233293 一.Python对象持久化方法 目前为止,据我所知,在python中对象持久化有 ...