Home > database >  Get results with all values after decimal in pandas series
Get results with all values after decimal in pandas series

Time:12-06

I have a dataframe where the time values are something like 8.000024 due to high sampling rate. When I extract these values from DF, the series shows the time values as 8.0 and I would like to have the full values. How do I do this ? My code is as below:

x = str(input('Enter file name with extension: ')) 
df = pd.read_csv(x, delimiter=";", dtype=float, na_values=["-∞", "∞"],)  # loads the csv files

time = df['Time'].astype('float')
time.round(6)
print(time)

CodePudding user response:

I ran your code and the output is

import pandas as pd

df = pd.DataFrame({
    "Time": [
        6.001234154,
        7.000124131,
        8.000024465,
        9.00000112234,
        10.00000023254,
        11.000000012410149,
    ]
})

time = df['Time'].astype('float')
time.round(6)
print(time)

Make sure the data is correct in your sourcefiles. Can't say more since your example isn't reproducible.

If you still have issues, please give a snippet/export from your sourcefile.

0     6.001234
1     7.000124
2     8.000024
3     9.000001
4    10.000000
5    11.000000
Name: Time, dtype: float64

Edit

The sourcefile was linked. And the file's first line is 8.00E 00;3.09E-03;1.97E-03;3.41E-03;3.66E-03;3.88E-03;2.44E-03

So resaving your ascii as csv must have rounded the numbers to 2 significant digits.

CodePudding user response:

Maybe the colums are too tight to display all the values, if it's the case, this would work : options.display.max_colwidth. It is use to see more in the default representation.

use pd.options.display.max_colwidth = 100
  • Related