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)


上一篇:使用Genism进行词向量训练
下一篇:airflow中dag上下文context传参数

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