We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I try to round all values in this dataframe. However, the pandas round() method explodes my dataframe from 150 rows to 7518 rows.
Perhaps there is something odd with the data in the dataframe, but then again, one would not expect a simple rounding function to do this.
Below, I replicate the error using 1) simulated data and 2) the data that leads to the said error.
This results in 150 rows, which is the correct number:
import pandas as pd import numpy as np df = pd.DataFrame(np.random.random([150, 4]), columns=['A', 'B', 'C', 'D']) df["cat"] = "MID" df.loc[:399,["cat"]] = "LOW" df.iloc[-400:,-1] = "HI" df.cat.value_counts() df.set_index("cat", inplace=True) df.round(3)
Using the data from my dropbox folder, the round-function produces a whopping 7518 rows:
dfb = pd.read_pickle('dfna.pkl') dfb.round(3)
This is strange. I solved it for now using this rather ugly line:
dfb = dfb.reset_index().round({'A': 1, 'B': 2, 'C': 3, 'D': 4}).set_index('tricile')
However, this is not ideal, given that pandas' round method acts in mysterious ways and may affect future programs.
The text was updated successfully, but these errors were encountered:
Can you try making a simple, reproducible example that demonstrates the issue? http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports
We can't use pickle files for a unit test.
Sorry, something went wrong.
Actually, this looks like #21809
No branches or pull requests
I try to round all values in this dataframe. However, the pandas round() method explodes my dataframe from 150 rows to 7518 rows.
Perhaps there is something odd with the data in the dataframe, but then again, one would not expect a simple rounding function to do this.
Below, I replicate the error using 1) simulated data and 2) the data that leads to the said error.
This results in 150 rows, which is the correct number:
Using the data from my dropbox folder, the round-function produces a whopping 7518 rows:
This is strange. I solved it for now using this rather ugly line:
However, this is not ideal, given that pandas' round method acts in mysterious ways and may affect future programs.
The text was updated successfully, but these errors were encountered: