There's a %
in the following code, which is from ARIMA Model in Python .
from statsmodels.tsa.stattools import adfuller
from numpy import log
result = adfuller(df.value.dropna())
print('ADF Statistic: %f' % result[0])
print('p-value: %f' % result[1])
I'm confused to what the %
does in the print statement (last line). What does it do to the result?
Or, does it represent mod?
Thanks!
The %
symbol is related to string interpolation rather then the print
. It is a way to format string. You can read here more about it.
It is just one of many ways to format strings in python:
- “Old Style” String Formatting (% Operator)
- “New Style” String Formatting (str.format)
- String Interpolation / f-Strings (Python 3.6+)
- Template Strings (Standard Library)