I want to export following chart to LaTex and replace my '+/-' with '±', just for the looks. Though, no matter what character I try (could also be an 'a' or anything else) it either doesn't change a bit or the column is empty. I found the code on several forums and I don't know what I'm doing wrong.
df = pd.DataFrame({'A': ["3.90+/-0.04", "3.550+/-0.035", "3.250+/-0.033"],'B': [0.04175, 0.03800, 0.03490]})
df=df.replace("+/-", "±", regex=False)
print(df)
df.to_latex('232_a.txt', index=False, encoding="ISO-8859-1")
I'd appreciate any kind of help. Thanks in advance!
You may use
df['A'] = df['A'].str.replace("+/-", "±", regex=False)
Output:
A B
0 3.90±0.04 0.04175
1 3.550±0.035 0.03800
2 3.250±0.033 0.03490
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.