关于如何将列设置为显示的行,并因此将行显示为pandas中的列的任何想法?
目前正在打印数据框输出如下:
K T best_testing_rmse best_training_rmse chan_out_dim \
48 15 20000 1.24502685 1.24942538 15
217 15 20000 1.25521732 1.24871174 15
dropout_p g_hid g_in g_latent g_rij \
48 0.1 tanh elu linear sigmoid
217 0.1 tanh elu linear sigmoid
harvest_dir hid_dim input_dropout_p \
48 ./harvest_autorec_20170103_175735 50 0.1
217 ./harvest_autorec_20170103_175730 50 0.1
last_testing_rmse last_training_rmse lr max_epoch \
48 1.52006088 1.52138316 0.000002 1403
217 1.31366942 1.30483602 0.000002 1056
minibatch_size n_epochs n_hid_layers optimizer preprocessing_type \
48 1 20000 1 gpu_omp zscore
217 1 20000 1 gpu_omp zscore
regression_error_coef regression_type regularization_lambda \
48 0.5 item 0.001
217 0.5 item 0.001
regularization_latent_kl stochastic_prediction upd
48 0.5 False adam_symbolic
217 0.5 False adam_symbolic
这特别不方便。更好的观察这张桌子旋转了90度。
答案 0 :(得分:1)
您要求的是transpose
,In [31]:
df = pd.DataFrame(np.random.randn(5,3), index=list('vwxyz'), columns=list('abc'))
df
Out[31]:
a b c
v 0.218951 -0.716086 0.620063
w -0.672559 0.311909 0.326861
x 0.866325 -0.591517 -0.387572
y -0.749873 1.645110 -1.185780
z -0.796720 -1.974399 0.546645
In [32]:
df.T
Out[32]:
v w x y z
a 0.218951 -0.672559 0.866325 -0.749873 -0.796720
b -0.716086 0.311909 -0.591517 1.645110 -1.974399
c 0.620063 0.326861 -0.387572 -1.185780 0.546645
可以使用.T
调用,它会旋转df,使列成为行,反之亦然:
<Path StrokeThickness="1" Stroke="White" Fill="Transparent">
<Path.Data>
<PathGeometry>
<PathFigure StartPoint="0,0">
<PolyLineSegment Points="10,10 0,20"/>
<LineSegment Point="0,0" IsStroked="False"/>
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>