吴裕雄 python 数据处理(1)
import time
print(time.time())
print(time.localtime())
print(time.strftime('%Y-%m-%d %X',time.localtime()))
绘图显示中文配置
import matplotlib.pyplot as plt
a = [1,1,2,3]
b = [2,2,2,2]
plt.plot(a,b)
plt.title("天生自然")
plt.show()
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv")
print(df.head())
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
print(df.head())
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
df.to_csv("E:\\temp\\taobao_price_data.csv", columns=["宝贝","价格"],index=False,header=True)
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
print(df[0:3])
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
cols = df[["宝贝","价格"]]
print(cols.head())
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df.ix[0:3,["宝贝","价格"]]
print(a)
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
df["销售量"] = df["价格"]*df["成交量"]
print(df.head())
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df[(df["价格"]<100)&(df["成交量"]<10000)]
print(a)
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
print(df.head())
df1 = df.set_index("位置")
print(df1.head())
df2 = df1.sort_index()
print(df2.head())
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
df1 = df.set_index(["位置","卖家"])
print(df1.head())
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
df1 = df.set_index(["位置","卖家"]).sortlevel(0)
print(df1.head())
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df.drop(["宝贝","卖家"],axis=1)
print(a.head())
b = df.drop(["宝贝","卖家"],axis=1).groupby("位置")
print(b.head())
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df.drop(["宝贝","卖家"],axis=1).groupby("位置").mean()
print(a.head())
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df.drop(["宝贝","卖家"],axis=1).groupby("位置").mean().sort_values("成交量",ascending=False)
print(a.head())
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df.drop(["宝贝","卖家"],axis=1).groupby("位置").sum().sort_values("成交量",ascending=False)
print(a.head())
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
print(df.info())
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
print(df.describe())
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
print(df.describe(include=["object"]))
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df["成交量"].groupby(df["位置"])
print(a.head())
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df["成交量"].groupby(df["位置"]).mean()
print(a.head())
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df["成交量"].groupby([df["位置"],df["卖家"]]).mean()
print(a.head())
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df.groupby("位置").mean()
print(a.head())
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df.groupby(["位置","卖家"]).mean()
print(a.head())
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df.groupby(["位置","卖家"]).size()
print(a.head())
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df[30:35][["位置","卖家"]]
print(a)
b = df[90:95][["卖家","成交量"]]
print(b)
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df[30:35][["位置","卖家"]]
b = df[30:35][["卖家","成交量"]]
c = pd.merge(a,b)
print(c)
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df[30:35][["位置","卖家"]]
b = df[30:35][["卖家","成交量"]]
c = pd.merge(a,b,on="卖家")
print(c)
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df[10:20][["位置","卖家"]]
b = df[30:40][["卖家","成交量"]]
c = pd.merge(a,b,how="outer")
print(c)
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df[10:20][["位置","卖家"]]
b = df[30:40][["卖家","成交量"]]
c = pd.merge(a,b,how="left")
print(c)
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df[10:20][["位置","卖家"]]
b = df[30:40][["卖家","成交量"]]
c = pd.merge(a,b,how="right")
print(c)
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df[:10][["位置","卖家"]]
print(a)
b = df[:10][["卖家","成交量"]]
print(b)
c = pd.merge(a,b,how="right")
print(c)
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df[:10][["位置","卖家"]]
b = df[:10][["卖家","成交量"]]
c = pd.merge(a,b,left_index=True,right_index=True)
print(c)
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df[:10][["位置","卖家"]]
b = df[:10][["价格","成交量"]]
c = pd.merge(a,b,left_index=True,right_index=True)
print(c)
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df[:10][["位置","卖家"]]
b = df[:10][["价格","成交量"]]
c = a.join(b)
print(c)
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df[:5]["宝贝"]
b = df[5:10]["宝贝"]
c = df[10:15]["宝贝"]
d = pd.concat([a,b,c])
print(d)
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df[:5]["宝贝"]
print(a)
b = df[:5]["价格"]
print(b)
c = df[:5]["成交量"]
print(c)
d = pd.concat([a,b,c],axis=1)
print(d)
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df[:5][["位置","卖家"]]
print(a)
b = df[:5][["价格","成交量"]]
print(b)
c = pd.concat([a,b])
print(c)
import pandas as pd
df = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\taobao_data.csv",delimiter=",",encoding="utf8",header=0)
a = df[:5][["位置","卖家"]]
print(a)
b = df[:5][["价格","成交量"]]
print(b)
c = pd.concat([a,b],axis=1)
print(c)
吴裕雄 python 数据处理(1)的更多相关文章
- 吴裕雄 python 数据处理(3)
import time a = time.time()print(a)b = time.localtime()print(b)c = time.strftime("%Y-%m-%d %X&q ...
- 吴裕雄 python 数据处理(2)
import pandas as pd data = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\hz ...
- 吴裕雄 python 神经网络——TensorFlow 输入数据处理框架
import tensorflow as tf files = tf.train.match_filenames_once("E:\\MNIST_data\\output.tfrecords ...
- 吴裕雄 python神经网络 花朵图片识别(10)
import osimport numpy as npimport matplotlib.pyplot as pltfrom PIL import Image, ImageChopsfrom skim ...
- 吴裕雄 python神经网络 花朵图片识别(9)
import osimport numpy as npimport matplotlib.pyplot as pltfrom PIL import Image, ImageChopsfrom skim ...
- 吴裕雄 python 神经网络——TensorFlow pb文件保存方法
import tensorflow as tf from tensorflow.python.framework import graph_util v1 = tf.Variable(tf.const ...
- 吴裕雄 python 神经网络——TensorFlow 花瓣分类与迁移学习(4)
# -*- coding: utf-8 -*- import glob import os.path import numpy as np import tensorflow as tf from t ...
- 吴裕雄 python 神经网络——TensorFlow 花瓣分类与迁移学习(3)
import glob import os.path import numpy as np import tensorflow as tf from tensorflow.python.platfor ...
- 吴裕雄 python 神经网络——TensorFlow 花瓣分类与迁移学习(2)
import glob import os.path import numpy as np import tensorflow as tf from tensorflow.python.platfor ...
随机推荐
- windows环境下把Python代码打包成独立执行的exe可执行文件
有时候因为出差,突然急需处理一批数据.虽然写好的脚本存储在云端随用随取,然而编译的环境还需要重新搭建,模块也需要重新装载,从头到尾这么一遍下来,也是要花费可观的时间成本的. 有没有什么办法,可以让.p ...
- 快速接入PHP微信支付
微信支付是微信开发中坑最多的一个功能,本文旨在帮助有开发基础的人快速接入微信支付,如果要详细了解微信支付,请看微信支付的开发文档. 再说把开发文档搬到这里来就没必要了.想要快速跑通微信支付的可以继续查 ...
- AWS ECU SSH无法连接问题处理
AWS ECU SSH无法连接问题处理,因同事误操作导致/var/empty/sshd目录权限为771,需要修改为711,因AWS只有一台实例,所以需要通过建立临时实例来挂载“卷”来修改/var/ ...
- 纯文本文件 numbers.txt, 里面的内容(包括方括号)如下所示
from collections import OrderedDict import xlwt with open('student.txt','r') as f: number_list = jso ...
- 分布式开放消息系统RocketMQ的原理与实践(消息的顺序问题、重复问题、可靠消息/事务消息)
备注:1.如果您此前未接触过RocketMQ,请先阅读附录部分,以便了解RocketMQ的整体架构和相关术语2.文中的MQServer与Broker表示同一概念 分布式消息系统作为实现分布式系统可扩展 ...
- 廖雪峰Java1-1Java入门-java简介
Java特点: 一种面向对象的跨平台变成语言 以字节码方式运行在虚拟机上 自带功能齐全的类库 非常活跃的开源社区支持 Java优点: 简单.健壮.安全 跨平台,一次编写,到处运行 高度优化的虚拟机 J ...
- 自己根据js的兼容封装了一个小小的js库
var gys = function () { } //oParent父节点 //获取所有的子元素 gys.prototype.getElementChildren = function (oPare ...
- Maven 配置tomcat插件
使用tomcat插件来访问maven 1 先下载tomcat插件(在pom中配置) <!-- 配置Tomcat插件 --> <plugin> <groupId>or ...
- Keras实现简单BP神经网络
BP 神经网络的简单实现 from keras.models import Sequential #导入模型 from keras.layers.core import Dense #导入常用层 tr ...
- CentOS重新加载网卡报错 Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/
重新加载网卡时出现的错误如下: 1 [root@vdb1 dev]# service network restart 2 Shutting down interface eth0: Device st ...