“Python编程”版本间的差异
来自iCenter Wiki
(→参考书) |
|||
第35行: | 第35行: | ||
=参考书= | =参考书= | ||
− | + | #Stanford U., CS231n, http://cs231n.github.io/python-numpy-tutorial/. | |
+ | #ICML-2017 TensorFlow workshop, https://github.com/random-forests/tensorflow-workshop/. | ||
#Lutz, Mark. Learning python. " O'Reilly Media, Inc.", 2013. | #Lutz, Mark. Learning python. " O'Reilly Media, Inc.", 2013. |
2017年11月4日 (六) 05:51的版本
python语言
文件读取:csv(pandas库),图片(pilllow库),其他(字符串处理)
Pandas库使用
#/usr/bin/python # -*- coding: utf-8 -*-
import pandas as np import sys
df = np.read_csv("traffic.txt", header=None)
for x in range(0,10): df.to_csv("%d.csv" %x, columns=[x], header=True, index=False)
Numpy库使用
Numpy数据操作:基本操作(dtype,reshape,transpose),数据切分(下标访问,random.sample等等)
以下代码绘制sin(x)/x函数:
import matplotlib.pyplot as plt import numpy as np
x = np.linspace(-10,10,1000)
sink = lambda x: np.sin(x)/x
plt.plot(x, sink(x), color='blue', lw=2)
plt.show()
参考书
- Stanford U., CS231n, http://cs231n.github.io/python-numpy-tutorial/.
- ICML-2017 TensorFlow workshop, https://github.com/random-forests/tensorflow-workshop/.
- Lutz, Mark. Learning python. " O'Reilly Media, Inc.", 2013.