Search code examples
pythonkaggle

why there is a "." after the number 3600?


def time_since_last_project(series):
    # Return the time in hours
    return series.diff().dt.total_seconds() / 3600.

~The code is from kaggle course, but why there is a "." after 3600?Please help me~


Solution

  • It specifies the type as float.

    If you check

    # Python2.7
    print(type(3600.))
    

    You will get that it is a float.

    Without the period,

    # Python2.7
    print(type(3600))
    

    You get int.

    This changes the type of division you are using: floating point arithmetic or integer arithmetic.

    Look at these two examples to see the difference.

    # Python2.7
    1 / 2 # = 0
    1 / 2. # = 0.5
    

    This is the significance of writing 3600., the writer of the code wanted to specify to use floating point division.