我有以下内容:
import pandas as pd
def TupFirst(x):
return x[0]
def TupSecond(x):
return x[1]
df = pd.DataFrame(data = {'colX': [(51.2990505474, 0.802680507953),(51.7491674401, -4.96357522689)]})
df['colY'] = df['colX'].apply(TupFirst)
df['colZ'] = df['colX'].apply(TupSecond)
df
返回以下数据框:
colX colY colZ
0 (51.2990505474, 0.802680507953) 51.299051 0.802681
1 (51.7491674401, -4.96357522689) 51.749167 -4.963575
为什么colY和colZ中的值被舍入?
答案 0 :(得分:2)
您所看到的是熊猫中显示配置的结果。完全精确仍然存在。检查一下:
print(df.loc[1, 'colz'])