2
無索引,漂亮,列
我經常發現自己寫的代碼像這樣得到很好地格式化,以多列輸出(無指標)在大熊貓調試或學習我的數據時:內置,輸出與熊貓
dfs = dfs[dfs['some_id'] == the_id]
cols = [
'some_col',
'another_col',
'yet_another',
]
print("\t".join(cols))
for row in dfs[cols].values:
print("\t\t".join([str(val) for val in row]))
這工作正常,但我想知道是否有內置的方式來獲得這種輸出與熊貓功能或直接查找語法。輸出示例:
some_col another_col yet_another
a b c
x y z
我通常用它來查看所有或單列。我如何使用它來選擇總列的子集? –
@JB在頂部添加了對特定代碼的編輯。 –