#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. 【矩阵哈希】【二分答案】【哈希表】bzoj1567 [JSOI2008]Blue Mary的战役地图

    引用题解:http://hzwer.com/5153.html 当然,二分可以换成哈希表. #include<cstdio> #include<iostream> #inclu ...

  2. Problem A: 调用函数,求三个数中最大数

    #include<stdio.h> int max(int a,int b,int c); int main() { int a,b,c; while(scanf("%d %d ...

  3. Problem K: 数字菱形

    #include<stdio.h> int main() { int n,i,j,k,t,x,q,p; while(scanf("%d",&n)!=EOF) ; ...

  4. IOS后台运行 之 后台播放音乐

    iOS 4开始引入的multitask,我们可以实现像ipod程序那样在后台播放音频了.如果音频操作是用苹果官方的AVFoundation.framework实现,像用AvAudioPlayer,Av ...

  5. 全局对象Application的使用,以及如何在任何地方得到Application全局对象

    Application和Activity,Service一样是android框架的一个系统组件,当android程序启动时系统会创建一个application对象,用来存储系统的一些信息.通常我们是不 ...

  6. .NET反编译

    http://www.cnblogs.com/powertoolsteam/archive/2011/01/05/1926066.html

  7. java 的 CopyOnWriteArrayList类

    初识CopyOnWriteArrayList 第一次见到CopyOnWriteArrayList,是在研究JDBC的时候,每一个数据库的Driver都是维护在一个CopyOnWriteArrayLis ...

  8. JAVA常见算法题(二十五)

    /** * Java实现中文数字转换为阿拉伯数字 * * * @author WQ * */ public class Demo26 { public static void main(String[ ...

  9. 阿里云RDS(云数据库)之产品简介

    参考阿里产品文档:https://docs.aliyun.com/?spm=5176.100054.3.1.ywnrMX#/pub/rds/product-introduce/overview& ...

  10. Yii2系列教程六:集成编辑器

    上一篇文章我们实现了简单的用户权限管理,至于更先进的RBAC,我后面会单独出一篇文章来说说.在这一篇文章当中,我主要想写的是在Yii2中集成一个编辑器,因为在我们的实际开发当中,一个简单的textar ...