我有以下 Dataframe
import pandas as pd data = [[0.8,0.23], [0.3,.40], [0.6,0.8], [0.7,0.9]] df = pd.DataFrame(data, columns=['A','B']) df
字符串我的预期输出是
List= [(0.8,0.23), (0.3,.40), (0.6,0.8), (0.7,0.9)]
型
l2osamch1#
替代方法:
data = [[0.8,0.23], [0.3,.40], [0.6,0.8], [0.7,0.9]] df = pd.DataFrame(data, columns=['A','B']) lst = [tuple(df.loc[x]) for x in df.index] print(lst)
字符串
f1tvaqid2#
to_record()方法尝试使用它:
to_record()
data_list = list(df.to_records(index=False)) print(data_list)
2条答案
按热度按时间l2osamch1#
替代方法:
字符串
f1tvaqid2#
to_record()
方法尝试使用它:
字符串