热线电话:13121318867

登录
2018-12-11 阅读量: 1150
怎么实现矩阵里的转置

import pandas as pd

import numpy as np

import matplotlib.pyplot as plt

s=pd.Series([1,3,5,np.nan,6,8])

dates=pd.date_range('20130101',periods=6)

df=pd.DataFrame(np.random.rand(6,4),index=dates,columns=list('ABCD'))

A B C D

2013-01-01 0.615859 0.354072 0.741003 0.055112

2013-01-02 0.985261 0.017241 0.481214 0.538970

2013-01-03 0.104701 0.647015 0.812034 0.477090

2013-01-04 0.252073 0.862004 0.063743 0.900931

2013-01-05 0.079194 0.779128 0.907441 0.659853

2013-01-06 0.790942 0.906111 0.093382 0.032258

df.T

2013-01-01 00:00:00 2013-01-02 00:00:00 2013-01-03 00:00:00 2013-01-04 00:00:00 2013-01-05 00:00:00 2013-01-06 00:00:00

A 0.615859 0.985261 0.104701 0.252073 0.079194 0.790942

B 0.354072 0.017241 0.647015 0.862004 0.779128 0.906111

C 0.741003 0.481214 0.812034 0.063743 0.907441 0.093382

D 0.055112 0.538970 0.477090 0.900931 0.659853 0.032258

0.0000
4
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子