As mentioned in the comments, it is a general floating point problem.
However you can use the float_format
key word of to_csv
to hide it:
df.to_csv('pandasfile.csv', float_format="%.3f")
or, if you don’t want 0.0001 to be rounded to zero:
df.to_csv('pandasfile.csv', float_format="%g")
will give you:
Bob,0.085
Alice,0.005
in your output file.
For an explanation of %g
, see Format Specification Mini-Language.
Related Contents:
- Convert pandas dataframe to NumPy array
- pandas create new column based on values from other columns / apply a function of multiple columns, row-wise
- What does axis in pandas mean?
- Split (explode) pandas dataframe string entry to separate rows
- How can I map True/False to 1/0 in a Pandas DataFrame?
- Counting unique values in a column in pandas dataframe like in Qlik?
- NumPy or Pandas: Keeping array type as integer while having a NaN value
- Binning a column with pandas
- What is the difference between NaN and None?
- Efficiently checking if arbitrary object is NaN in Python / numpy / pandas?
- Performance of Pandas apply vs np.vectorize to create new column from existing columns
- How to use sklearn fit_transform with pandas and return dataframe instead of numpy array?
- How to get value counts for multiple columns at once in Pandas DataFrame?
- Ambiguity in Pandas Dataframe / Numpy Array “axis” definition
- Pass percentiles to pandas agg function
- Coalesce values from 2 columns into a single column in a pandas dataframe
- How to one-hot-encode from a pandas column containing a list?
- Pandas: Subtracting two date columns and the result being an integer
- Get index of a row of a pandas dataframe as an integer
- Importing data from a MySQL database into a Pandas data frame including column names [duplicate]
- pandas select from Dataframe using startswith
- ValueError: numpy.dtype has the wrong size, try recompiling
- Python Pandas – Changing some column types to categories
- Pandas Split Dataframe into two Dataframes at a specific row
- What’s the fastest way in Python to calculate cosine similarity given sparse matrix data?
- How to convert list of model objects to pandas dataframe?
- ValueError: Unknown label type: ‘unknown’
- shuffling/permutating a DataFrame in pandas
- Find out the percentage of missing values in each column in the given dataset
- Suppressing scientific notation in pandas? [duplicate]
- Get the mean across multiple Pandas DataFrames
- Pandas Timedelta in Days
- Pandas in AWS lambda gives numpy error
- Cross-correlation (time-lag-correlation) with pandas?
- Creating Pandas Dataframe between two Numpy arrays, then draw scatter plot
- How to check if a variable is either a python list, numpy array or pandas series
- Finding count of distinct elements in DataFrame in each column
- Comparing previous row values in Pandas DataFrame
- Improve Row Append Performance On Pandas DataFrames
- Fast Haversine Approximation (Python/Pandas)
- Output different precision by column with pandas.DataFrame.to_csv()?
- Set values on the diagonal of pandas.DataFrame
- When to use pandas series, numpy ndarrays or simply python dictionaries?
- Scikit-Learn’s Pipeline: A sparse matrix was passed, but dense data is required
- Convert numpy type to python
- which is faster for load: pickle or hdf5 in python
- When to apply(pd.to_numeric) and when to astype(np.float64) in python?
- Calculate average of every x rows in a table and create new table
- pd.NA vs np.nan for pandas
- Python Numpy TypeError: ufunc ‘isfinite’ not supported for the input types