[英]How to print a dataframe in oneline without including None?
我有以下數據框
0 1 2 3
A b a p l
C c p g None
T g t x None
現在我正在打印它,如下所示
for i in range(len(df.columns)): print((df[i]).to_string(index=False))
輸出:
b
c
g
a
p
t
p
g
x
l
None
None
有沒有辦法像這樣打印它?
bcgaptpgxl
假設None
實際上是NaN
:
>>> ''.join(df.melt()['value'].dropna().tolist())
'bcgaptpgxl'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.