0

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!

1 Answer 1

4

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.