0

When I create a dataframe from a excel file, it has a string value '2098E10'. But pandas interpret the letter E on string as scientific notation converting the value to 20980000000000. How can I suppress this panda's behavior to keep the values '2098E10' as string?

I have tried to convert the values to string, but the value will be '20980000000000'.

1
  • Specify the dtype when using read_excel? Commented Nov 7, 2022 at 20:12

1 Answer 1

1

You should use pandas.read_csv with the correct dtype argument (str for you), e.g.

pd.read_csv('data/data_7.csv',
                 dtype={
                     'Name': str,
                     'Grade': int
                 })

Hint taken from this blog post #5.

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.