-
Notifications
You must be signed in to change notification settings - Fork 9
/
06_CT_Pandas.Rmd
3134 lines (2518 loc) · 54.1 KB
/
06_CT_Pandas.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Pandas 学习教程 {#py3_pandas_ct}
欢迎访问我们的视频课程 <https://bioinfo.ke.qq.com>。
## What is pandas
Pandas是python中用于处理矩阵样数据的功能强大的包,提供了R中的`dataframe`和`vector`的操作,使得我们在使用python时,也可以方便、简单、快捷、高效地进行矩阵数据处理。
具体介绍详见<http://pandas.pydata.org/>。
* A fast and efficient **DataFrame** object for data manipulation with integrated indexing;
* Tools for reading and writing data between in-memory data structures and different formats: CSV and text files, Microsoft Excel, SQL databases, and the fast **HDF5** format;
* Intelligent **data alignment** and integrated handling of missing data: gain automatic label-based alignment in computations and easily manipulate **messy data into an orderly form**;
* Flexible **reshaping** and **pivoting** of data sets;
* Intelligent label-based slicing, fancy indexing, and subsetting of large data sets;
* Columns can be inserted and deleted from data structures for size mutability;
* Aggregating or transforming data with a powerful group by engine allowing split-apply-combine operations on data sets;
* High performance **merging** and **joining** of data sets;
* Hierarchical axis indexing provides an intuitive way of working with high-dimensional data in a lower-dimensional data structure;
* Time series-functionality: date range generation and frequency conversion, moving window statistics, moving window linear regressions, date shifting and lagging. Even create domain-specific time offsets and join time series without losing data;
* Highly optimized for performance, with critical code paths written in Cython or C.
* Python with pandas is in use in a wide variety of academic and commercial domains, including Finance, Neuroscience, Economics, Statistics, Advertising, Web Analytics, and more.
```python
%matplotlib inline
#import plotly
#plotly.offline.init_notebook_mode()
import matplotlib
matplotlib.style.use('ggplot')
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import os
from glob import glob
```
## Pandas读取文件
### 获取目标文件
```python
dir_1 = "py_data/"
glob(dir_1+'*')
```
['py_data/ENCFF060LPA.tsv',
'py_data/ENCFF262OBL.tsv',
'py_data/ENCFF289HGQ.tsv',
'py_data/ENCFF673KYR.tsv',
'py_data/gencode.v24.ENS2SYN',
'py_data/meta.tsv',
'py_data/gencode.gene.gtf',
'py_data/gencode.gene.bed12',
'py_data/ensm.id',
'py_data/GRCh38.idmap']
### 查看目标文件内容和格式
Ipython中可以通过在Linux命令前加`!`调用系统命令,更多使用见
http://ipython.org/ipython-doc/3/interactive/reference.html#system-shell-access.
```python
!head -n 4 py_data/gencode.v24.ENS2SYN
```
gene_id gene_symbol
ENSG00000001460.17 STPG1
ENSG00000001461.16 NIPAL3
ENSG00000000938.12 FGR
```python
!head -n 4 py_data/ENCFF060LPA.tsv
```
gene_id transcript_id(s) length effective_length expected_count TPM FPKM
ENSG00000000003.14 ENST00000373020.8,ENST00000494424.1,ENST00000496771.5,ENST00000612152.4,ENST00000614008.4 2240.53 2020.49 5126.00 6.64 18.24
ENSG00000000005.5 ENST00000373031.4,ENST00000485971.1 940.50 720.47 0.00 0.00 0.00
ENSG00000000419.12 ENST00000371582.8,ENST00000371584.8,ENST00000371588.9,ENST00000413082.1,ENST00000466152.5,ENST00000494752.1 1072.03 851.99 3222.00 9.91 27.19
### 读取两列文件
```python
ens2syn_file = dir_1+"/gencode.v24.ENS2SYN"
```
```python
# pandas中的计数都是从0开始的
# header=0: 指定第一行包含列的名字
# index_col=0: 指定第一列为行的名字
ens2syn = pd.read_table(ens2syn_file, header=0, index_col=0)
```
```python
ens2syn.head()
```
<!--html_preserve-->
<div>
<style>
.dataframe thead tr:only-child th {
text-align: right;
}
.dataframe thead th {
text-align: left;
}
.dataframe tbody tr th {
vertical-align: top;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>gene_symbol</th>
</tr>
<tr>
<th>gene_id</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<th>ENSG00000001460.17</th>
<td>STPG1</td>
</tr>
<tr>
<th>ENSG00000001461.16</th>
<td>NIPAL3</td>
</tr>
<tr>
<th>ENSG00000000938.12</th>
<td>FGR</td>
</tr>
<tr>
<th>ENSG00000004455.16</th>
<td>AK2</td>
</tr>
<tr>
<th>ENSG00000000460.16</th>
<td>C1orf112</td>
</tr>
</tbody>
</table>
</div>
<!--/html_preserve-->
### 数据表的索引
* 数值索引和布尔值索引是按行选取
* 字符串索引是按列选取
* 行和列是等效的,应用于行的选取函数也可应用于列,反之亦然
#### 按行选取数据
```python
ens2syn[:3]
```
<!--html_preserve-->
<div>
<style>
.dataframe thead tr:only-child th {
text-align: right;
}
.dataframe thead th {
text-align: left;
}
.dataframe tbody tr th {
vertical-align: top;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>gene_symbol</th>
</tr>
<tr>
<th>gene_id</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<th>ENSG00000001460.17</th>
<td>STPG1</td>
</tr>
<tr>
<th>ENSG00000001461.16</th>
<td>NIPAL3</td>
</tr>
<tr>
<th>ENSG00000000938.12</th>
<td>FGR</td>
</tr>
</tbody>
</table>
</div>
<!--/html_preserve-->
#### 取出索引中包含特定值的行
```python
ens2syn[ens2syn.index=="ENSG00000001460.17"]
```
<!--html_preserve-->
<div>
<style>
.dataframe thead tr:only-child th {
text-align: right;
}
.dataframe thead th {
text-align: left;
}
.dataframe tbody tr th {
vertical-align: top;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>gene_symbol</th>
</tr>
<tr>
<th>gene_id</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<th>ENSG00000001460.17</th>
<td>STPG1</td>
</tr>
</tbody>
</table>
</div>
<!--/html_preserve-->
#### 取出某列包含特定值列表的行
```python
ens2syn[ens2syn['gene_symbol'].isin(['STPG1','FGR'])]
```
<!--html_preserve-->
<div>
<style>
.dataframe thead tr:only-child th {
text-align: right;
}
.dataframe thead th {
text-align: left;
}
.dataframe tbody tr th {
vertical-align: top;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>gene_symbol</th>
</tr>
<tr>
<th>gene_id</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<th>ENSG00000001460.17</th>
<td>STPG1</td>
</tr>
<tr>
<th>ENSG00000000938.12</th>
<td>FGR</td>
</tr>
</tbody>
</table>
</div>
<!--/html_preserve-->
#### 使用正则表达式选取符合要求的行
```python
# head: 只展示部分数据
ens2syn[ens2syn.index.str.contains(r'ENSG000000014')].head()
```
<!--html_preserve-->
<div>
<style>
.dataframe thead tr:only-child th {
text-align: right;
}
.dataframe thead th {
text-align: left;
}
.dataframe tbody tr th {
vertical-align: top;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>gene_symbol</th>
</tr>
<tr>
<th>gene_id</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<th>ENSG00000001460.17</th>
<td>STPG1</td>
</tr>
<tr>
<th>ENSG00000001461.16</th>
<td>NIPAL3</td>
</tr>
<tr>
<th>ENSG00000001497.16</th>
<td>LAS1L</td>
</tr>
</tbody>
</table>
</div>
<!--/html_preserve-->
### 读取多列文件
`gzip`, `bzip`压缩的文件也可以直接读取,但是需要保证文件后缀的正确。
`read_table`默认参数可以自动检测文件的格式,根据文件的后缀 '.gz', '.bz2', '.zip', or 'xz'分别使用 gzip, bz2, zip or xz读取。
```python
tsvL = glob(dir_1+'ENC*.tsv')
tsvL
```
['py_data/ENCFF060LPA.tsv',
'py_data/ENCFF262OBL.tsv',
'py_data/ENCFF289HGQ.tsv',
'py_data/ENCFF673KYR.tsv']
```python
index = 0
tsvFile = tsvL[index]
expr = pd.read_table(tsvFile, header=0, index_col=0)
expr.head(3)
```
<!--html_preserve-->
<div>
<style>
.dataframe thead tr:only-child th {
text-align: right;
}
.dataframe thead th {
text-align: left;
}
.dataframe tbody tr th {
vertical-align: top;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>transcript_id(s)</th>
<th>length</th>
<th>effective_length</th>
<th>expected_count</th>
<th>TPM</th>
<th>FPKM</th>
</tr>
<tr>
<th>gene_id</th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<th>ENSG00000000003.14</th>
<td>ENST00000373020.8,ENST00000494424.1,ENST000004...</td>
<td>2240.53</td>
<td>2020.49</td>
<td>5126.0</td>
<td>6.64</td>
<td>18.24</td>
</tr>
<tr>
<th>ENSG00000000005.5</th>
<td>ENST00000373031.4,ENST00000485971.1</td>
<td>940.50</td>
<td>720.47</td>
<td>0.0</td>
<td>0.00</td>
<td>0.00</td>
</tr>
<tr>
<th>ENSG00000000419.12</th>
<td>ENST00000371582.8,ENST00000371584.8,ENST000003...</td>
<td>1072.03</td>
<td>851.99</td>
<td>3222.0</td>
<td>9.91</td>
<td>27.19</td>
</tr>
</tbody>
</table>
</div>
<!--/html_preserve-->
### 选取多列数据
列的输出顺序与给定的列名字的顺序一致
```python
expr[['FPKM','TPM']].head(3)
```
<!--html_preserve-->
<div>
<style>
.dataframe thead tr:only-child th {
text-align: right;
}
.dataframe thead th {
text-align: left;
}
.dataframe tbody tr th {
vertical-align: top;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>FPKM</th>
<th>TPM</th>
</tr>
<tr>
<th>gene_id</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<th>ENSG00000000003.14</th>
<td>18.24</td>
<td>6.64</td>
</tr>
<tr>
<th>ENSG00000000005.5</th>
<td>0.00</td>
<td>0.00</td>
</tr>
<tr>
<th>ENSG00000000419.12</th>
<td>27.19</td>
<td>9.91</td>
</tr>
</tbody>
</table>
</div>
<!--/html_preserve-->
### 重命名列名字
从Dataframe中只选取一列时,数据框会被转换成**Series**,因此需要使用`pd.loc[:,[column_name]]`(虽然内部的方括号内只有一个值,但写法是必须的)索引。
```python
tsvFile
os.path.split(tsvFile)[-1][:-4]
```
'ENCFF060LPA'
```python
# 因为要把多个文件的同一类型表达值合并到一个文件,我们使用文件名作为列的名字
name = os.path.split(tsvFile)[-1][:-4]
print(name)
expr_tpm = expr.loc[:,['TPM']] # 取出所有的行和名字为TPM的列
#expr_tpm.head()
# 给列重命名
expr_tpm.columns=[name]
expr_tpm[:3]
```
ENCFF060LPA
<!--html_preserve-->
<div>
<style>
.dataframe thead tr:only-child th {
text-align: right;
}
.dataframe thead th {
text-align: left;
}
.dataframe tbody tr th {
vertical-align: top;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>ENCFF060LPA</th>
</tr>
<tr>
<th>gene_id</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<th>ENSG00000000003.14</th>
<td>6.64</td>
</tr>
<tr>
<th>ENSG00000000005.5</th>
<td>0.00</td>
</tr>
<tr>
<th>ENSG00000000419.12</th>
<td>9.91</td>
</tr>
</tbody>
</table>
</div>
<!--/html_preserve-->
### 合并矩阵
#### 定义函数简化文件读取
```python
# 为了读取多个文件,定义一个函数简化操作
def readExpr_1(tsvFileL, typeL=['TPM','FPKM']):
'''
tsvFileL: lists of files waiting for reading
resultD: a dictionary to save data matrix
{'TPM':[mat1, mat2,...]
'FPKM':[mat1, mat2, ...]}
typeL; list of names for columns to be extracted
'''
resultD = {}
for _type in typeL: resultD[_type] = []
for tsvFile in tsvFileL:
expr = pd.read_table(tsvFile, header=0, index_col=0)
name = os.path.split(tsvFile)[-1][:-4] #this option is very arbitary
for _type in typeL:
# add _ to type to avoid override Python inner function `type`
expr_type = expr.loc[:,[_type]]
expr_type.columns = [name]
resultD[_type].append(expr_type)
return resultD
#-----------------------------------------------------
```
```python
exprD = readExpr_1(tsvL)
TPM_mat = exprD['TPM']
FPKM_mat = exprD['FPKM']
```
#### 使用pd.merge合并矩阵示例
先从刚才读取的矩阵中选出2个测试下pandas中的矩阵合并方法和效果
```python
# 选取第一个矩阵
_idL = ['ENSG00000000003.14', 'ENSG00000000005.5','ENSG00000000419.12',
'ENSG00000000457.13']
mat1 = TPM_mat[0]
mat1 = mat1[mat1.index.isin(_idL)]
mat1
```
<!--html_preserve-->
<div>
<style>
.dataframe thead tr:only-child th {
text-align: right;
}
.dataframe thead th {
text-align: left;
}
.dataframe tbody tr th {
vertical-align: top;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>ENCFF060LPA</th>
</tr>
<tr>
<th>gene_id</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<th>ENSG00000000003.14</th>
<td>6.64</td>
</tr>
<tr>
<th>ENSG00000000005.5</th>
<td>0.00</td>
</tr>
<tr>
<th>ENSG00000000419.12</th>
<td>9.91</td>
</tr>
<tr>
<th>ENSG00000000457.13</th>
<td>0.86</td>
</tr>
</tbody>
</table>
</div>
<!--/html_preserve-->
```python
# 选取第二个矩阵
_idL = ['ENSG00000001561.6','ENSG00000000003.14', 'ENSG00000000419.12','ENSG00000001036.13']
mat2 = TPM_mat[1]
mat2 = mat2[mat2.index.isin(_idL)]
mat2
```
<!--html_preserve-->
<div>
<style>
.dataframe thead tr:only-child th {
text-align: right;
}
.dataframe thead th {
text-align: left;
}
.dataframe tbody tr th {
vertical-align: top;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>ENCFF262OBL</th>
</tr>
<tr>
<th>gene_id</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<th>ENSG00000000003.14</th>
<td>17.13</td>
</tr>
<tr>
<th>ENSG00000000419.12</th>
<td>18.86</td>
</tr>
<tr>
<th>ENSG00000001036.13</th>
<td>10.34</td>
</tr>
<tr>
<th>ENSG00000001561.6</th>
<td>2.47</td>
</tr>
</tbody>
</table>
</div>
<!--/html_preserve-->
基于索引(index)的合并
* outer: 合并所有的索引,缺失值填充NA
* inner:保留共有的索引
* left:使用第一个矩阵的索引
* right:使用第二个矩阵的索引
```python
pd.merge(mat1, mat2, left_index=True, right_index=True, how="outer")
```
<!--html_preserve-->
<div>
<style>
.dataframe thead tr:only-child th {
text-align: right;
}
.dataframe thead th {
text-align: left;
}
.dataframe tbody tr th {
vertical-align: top;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>ENCFF060LPA</th>
<th>ENCFF262OBL</th>
</tr>
<tr>
<th>gene_id</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<th>ENSG00000000003.14</th>
<td>6.64</td>
<td>17.13</td>
</tr>
<tr>
<th>ENSG00000000005.5</th>
<td>0.00</td>
<td>NaN</td>
</tr>
<tr>
<th>ENSG00000000419.12</th>
<td>9.91</td>
<td>18.86</td>
</tr>
<tr>
<th>ENSG00000000457.13</th>
<td>0.86</td>
<td>NaN</td>
</tr>
<tr>
<th>ENSG00000001036.13</th>
<td>NaN</td>
<td>10.34</td>
</tr>
<tr>
<th>ENSG00000001561.6</th>
<td>NaN</td>
<td>2.47</td>
</tr>
</tbody>
</table>
</div>
<!--/html_preserve-->
```python
pd.merge(mat1, mat2, left_index=True, right_index=True, how="inner")
```
<!--html_preserve-->
<div>
<style>
.dataframe thead tr:only-child th {
text-align: right;
}
.dataframe thead th {
text-align: left;
}
.dataframe tbody tr th {
vertical-align: top;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>ENCFF060LPA</th>
<th>ENCFF262OBL</th>
</tr>
<tr>
<th>gene_id</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<th>ENSG00000000003.14</th>
<td>6.64</td>
<td>17.13</td>
</tr>
<tr>
<th>ENSG00000000419.12</th>
<td>9.91</td>
<td>18.86</td>
</tr>
</tbody>
</table>
</div>
<!--/html_preserve-->
```python
pd.merge(mat1, mat2, left_index=True, right_index=True, how="left")
```
<!--html_preserve-->
<div>
<style>
.dataframe thead tr:only-child th {
text-align: right;
}
.dataframe thead th {
text-align: left;
}
.dataframe tbody tr th {
vertical-align: top;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>ENCFF060LPA</th>
<th>ENCFF262OBL</th>
</tr>
<tr>
<th>gene_id</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<th>ENSG00000000003.14</th>
<td>6.64</td>
<td>17.13</td>
</tr>
<tr>
<th>ENSG00000000005.5</th>
<td>0.00</td>
<td>NaN</td>
</tr>
<tr>
<th>ENSG00000000419.12</th>
<td>9.91</td>
<td>18.86</td>
</tr>
<tr>
<th>ENSG00000000457.13</th>
<td>0.86</td>
<td>NaN</td>
</tr>
</tbody>
</table>
</div>
<!--/html_preserve-->
#### 使用pd.concat合并矩阵示例