Pandas version checks
-
[x] I have checked that this issue has not already been reported.
-
[x] I have confirmed this bug exists on the latest version of pandas.
-
[x] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas
statafile = pandas.read_stata(statafilepath)
statafile["webphone"]
statafile["webphone"].round(2).astype(float)
round(statafile["webphone"],2).astype(float)
Issue Description
When rounding numbers that have been brought in from stata, rounding does not work as expected. The identical number imported from a postgres table does not have the same issue. You can see the issue in the image below:
Expected Behavior
Rounding a float should round it.
Installed Versions
Comment From: rhshadrach
Thanks for the report. In order to consider this issue, we need a reproducible example. If you take cstdata, write it as a CSV, and use pd.read_csv on this file, can you reproduce the behavior? If so, then you can post the plaintext of the data in the issue.
Alternatively, can you attach the stata file to the issue?
Please reduce it to a minimal example: only keep the rows / columns you need to demonstrate the issue.
Closing until a reproducer is provided - happy to reopen!
Comment From: CoreyBurger
Ok, minimal example attached. The DTA file is in a zip
MinRoundingExample.xlsx MinRoundingExample.csv MinRoundingExample.zip
To trigger these examples, the following code was used: Excelfile["webphone"] Excelfile["webphone"].round(3) statafile["webphone"] statafile["webphone"].round(3) CSVFile["webphone"] CSVFile["webphone"].round(3)
It produces the following results for me:
Comment From: CoreyBurger
For reference, all of these files were exported from a single Stata 18 instance running on Windows.