import time

a = time.time()
print(a)
b = time.localtime()
print(b)
c = time.strftime("%Y-%m-%d %X",time.localtime())
print(c)
d = time.mktime(time.localtime())
print(d)
e = time.strftime("%Y-%m-%d %X",time.localtime(1544103564.0))
print(e)

import datetime
import numpy as np
import pandas as pd

a = pd.date_range(datetime.datetime(2018,1,1),periods=31)
print(a)

import datetime
import numpy as np
import pandas as pd

a = pd.date_range("2018-1-1",periods=31)
print(a)

import datetime
import numpy as np
import pandas as pd

a = pd.date_range("2018-5-1 00:00","2018-5-1 12:00",freq="H")
print(a)

import datetime
import numpy as np
import pandas as pd

ts1 = pd.Series(np.arange(31),index=pd.date_range("2018-1-1",periods=31))
print(ts1.head())
print(ts1["2018-1-3"])
print(ts1.index[3])
a = ts1.index[3].year
b = ts1.index[3].month
c = ts1.index[3].day
print(a,b,c)

import datetime
import numpy as np
import pandas as pd

data = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\pandas data\\hz_weather.csv")
print(data.head())
df = data[["日期","最高气温","最低气温"]].set_index("日期")
print(type(df))
print(df.head())
print(df.index[0])
print(df.info())

import datetime
import numpy as np
import pandas as pd

data = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\pandas data\\hz_weather.csv")
df = data.set_index("日期")
a = np.array(df.index) < "2017-02-01"
print(a)
b = df[(df.index >= "2017-01-01")&(df.index < "2017-02-01")]
print(b)
print(b.info())

import datetime
import numpy as np
import pandas as pd

data = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\pandas data\\hz_weather.csv")
df = data.set_index("日期")
df = data[["日期","最高气温","最低气温"]].set_index("日期")
print(type(df))
print(df.head())
a = df.groupby(level=0).mean()
print(a.head())

%matplotlib inline

import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt

data = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\pandas data\\hz_weather.csv")
df = data.set_index("日期")
df = data[["日期","最高气温","最低气温"]].set_index("日期")
fig,ax = plt.subplots(1,1,figsize=(12,4))
df.plot(ax=ax)
plt.grid()
# ax.set_xticklabels(df.index.values)
# ax.set_xlabel(df.index.values)
plt.show()

import numpy as np
import pandas as pd

data = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\pandas data\\european_cities.csv")
print(np.shape(data))
print(data.head())
print(type(data.Population[0]))

import numpy as np
import pandas as pd

data = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\pandas data\\european_cities.csv")
print(data.head())
data["NumericPopulation"] = data.Population.apply(lambda x:int(x.replace(",","")))
print(data.head())

import numpy as np
import pandas as pd

data = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\pandas data\\european_cities.csv")
a = data["State"].values[:3]
print(a)

import numpy as np
import pandas as pd

data = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\pandas data\\european_cities.csv")
data["State"] = data["State"].apply(lambda x:x.strip())
print(data.head())
print(data.dtypes)

import numpy as np
import pandas as pd

data = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\pandas data\\getlinks.csv")
print(data.head())
a = data.link.str.extract("(\d+)")
print(a)
b = data.link.str.extract("(.*)/(\d+)")
print(b)

import numpy as np
import pandas as pd

data = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\pandas data\\getlinks.csv")
print(data.head())
b = data.link.str.extract("(?P<URL>.*)/(?P<ID>\d+)")
print(b)

吴裕雄 python 数据处理(3)的更多相关文章

  1. 吴裕雄 python 数据处理(2)

    import pandas as pd data = pd.read_csv("F:\\python3_pachongAndDatareduce\\data\\pandas data\\hz ...

  2. 吴裕雄 python 数据处理(1)

    import time print(time.time())print(time.localtime())print(time.strftime('%Y-%m-%d %X',time.localtim ...

  3. 吴裕雄 python 神经网络——TensorFlow 输入数据处理框架

    import tensorflow as tf files = tf.train.match_filenames_once("E:\\MNIST_data\\output.tfrecords ...

  4. 吴裕雄 python神经网络 花朵图片识别(10)

    import osimport numpy as npimport matplotlib.pyplot as pltfrom PIL import Image, ImageChopsfrom skim ...

  5. 吴裕雄 python神经网络 花朵图片识别(9)

    import osimport numpy as npimport matplotlib.pyplot as pltfrom PIL import Image, ImageChopsfrom skim ...

  6. 吴裕雄 python 神经网络——TensorFlow pb文件保存方法

    import tensorflow as tf from tensorflow.python.framework import graph_util v1 = tf.Variable(tf.const ...

  7. 吴裕雄 python 神经网络——TensorFlow 花瓣分类与迁移学习(4)

    # -*- coding: utf-8 -*- import glob import os.path import numpy as np import tensorflow as tf from t ...

  8. 吴裕雄 python 神经网络——TensorFlow 花瓣分类与迁移学习(3)

    import glob import os.path import numpy as np import tensorflow as tf from tensorflow.python.platfor ...

  9. 吴裕雄 python 神经网络——TensorFlow 花瓣分类与迁移学习(2)

    import glob import os.path import numpy as np import tensorflow as tf from tensorflow.python.platfor ...

随机推荐

  1. django练习题

    1.Web框架的本质是什么?为什么要有Web框架? 所有的Web应用,本质上其实就是一个socket服务端,用户端程序其实就是一个socket客户端.对于真实开发中的python web程序来说,一般 ...

  2. C#写Excel(OleDB)

    先辟谣(至少对Excel2010来说) IMEX ( IMport EXport mode )设置 IMEX 有三种模式,各自引起的读写行为也不同,容後再述: 0 is Export mode:只能写 ...

  3. es6(12)--类,对象

    //类,对象 { //基本定义和生成实例 class Parent{ //定义构造函数 constructor(name='QQQ'){ this.name=name; } } let v_paren ...

  4. day24类的继承

    类的继承1 什么是继承    继承一种新建类的方式,新建的类称之为子类/派生类,被继承的类称之为父类\基类\超类    python中继承的特点:        1. 子类可以遗传/重用父类的属性   ...

  5. Linux Git install

    1.介绍 使用Coding管理项目,上面要求使用的git版本为1.8.0以上,而很多yum源上自动安装的git版本为1.7,所以需要掌握手动编译安装git方法. 2.安装git依赖包 yum inst ...

  6. WPF DataGrid多表头/列头,多行头,合并单元格,一列占据多行

    先上效果图: 思路说明:这是两个DataGrid,没有嵌套,位置和高度保持一致,在加上ScrollViewer滚动条,这就像是在一个DataGrid中. 缺点: 因为最外层有透明的Border,所以没 ...

  7. 20165205 2017-2018-2 《Java程序设计》实验二 Java面向对象程序设计

    20165205 2016-2017-2 <Java程序设计>实验二 Java面向对象程序设计 实验内容 初步掌握单元测试和TDD 理解并掌握面向对象三要素:封装.继承.多态 初步掌握UM ...

  8. windows下mvn verify异常

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-jarsigner-plugin:1.4:sign (sign) on pr ...

  9. myeclipse内存调整

    内存调整: myeclipse.ini里配置后 1.设置Default VM Arguments 在myEclipse中,打开Windows-> Preferences->Java-> ...

  10. python中的find、rfind、index、rindex

    find()从左向右寻找子序列的位置,如存在多个相同子序列只返回第一个查找到的位置,如果子序列不存在返回-1 rfind()从右向左寻找子序列的位置..... index()从左向右寻找子序列的位置, ...