One - One Code All

Blog Content

python的dataframe和matrix的互换

Python 统计学-科学计算   2014-02-12 21:58:25
import pandas as pd
import numpy as np

mat = np.random.randn(3,4)
# mat 转为  pandas
df = pd.DataFrame(mat)

# dataframe 转为 mat
mat = df.as_matrix(columns=None)


ndarray 转为矩阵:


np.mat(array)


上一篇:word2vec模型原理与实现
下一篇:IDEA创建MAVEN项目卡住,修改为阿里镜像mirror

The minute you think of giving up, think of the reason why you held on so long.