python notes
来源:互联网 发布:linux samba配置详解 编辑:程序博客网 时间:2024/06/08 02:26
1. np.concatenate连接矩阵,然后reshape
import numpy as npx1 = np.array([[1,1], [1,1]])x2 = np.array([[2,2],[2,2]])x3 = np.concatenate((x1,x2))x3 = x3.reshape((x1.shape[0],2)+x1.shape[1:])print x3.shape#(2,2,2)
2. list相加和list.append()
colname_sum = ['date'] colname_sum= colname_sum + (list(range(2))) #['date', 0, 1] colname_append = ['date'] colname_append.append(list(range(2))) #['date', [0, 1]]
3. dataframe.copy()
df1 = df2 #citedf1 = df2.copy() #copy
4. df colname
col = range(5) col.append('label') df = pd.DataFrame(columns=col)
4. swap col
cols = list(df)cols.insert(0, cols.pop(cols.index('object')))df = df.ix[:, cols]
5. big endian&& min_max_scaler && img from array
raw = np.fromfile('c1_1.raw', dtype=np.int8)raw = np.ndarray(shape = (1081, 2571),dtype='>i2', buffer=raw)min_max_scaler = preprocessing.MinMaxScaler(feature_range=(0,255),copy=True)raw = min_max_scaler.fit_transform(raw)raw_img = Image.fromarray(raw)#PIL cannot write mode F to jpegif raw_img.mode != 'RGB': # raw_img = raw_img.convert('RGB') raw_img = raw_img.convert('L')
0 0
- Python Notes
- Python notes
- Python Notes
- python notes
- Python notes
- Python Notes
- Python Notes
- Python Notes
- python notes
- python-notes
- Python Notes
- Python Cookbook Notes Chapter1
- Python Reviewing Notes
- My python/java notes
- Notes on Python
- Core Python Notes
- Python Technical Notes
- [-]boost python notes
- ReentrantLock与synchronized
- select级联操作的简便方法
- 异星工场(Factorio)玩法分析与讨论
- struct原理
- 下定决心拿下散列表(Hash)
- python notes
- [基础]项目中Struts的配置
- js 使用Json数据
- [转]Struts1和Struts2 action的线程安全
- 怎么实现PHP的三种HTTP请求模拟post 提交 之一
- [转]struts2的action中获得request response session几种方法【基础】
- Liunx入门
- AndroidStudio:图片有jpg改为png之后报错
- 【ZOJ3956 The 17th Zhejiang University Programming Contest I】【01背包】Course Selection System 公式最大化