Pandas: print without dtype information

Viewed 2084

I have predictions.iloc[5]:

(predictions.iloc[5])
Out[102]: 
0    569.366922
Name: 5, dtype: float64

I also have mape

mape
Out[103]: 3.1396327381728257

I'm combining the two variables into forecast

forecast = ((predictions.iloc[5]), mape)

I'm trying to print without the Name: 5, dtype: float64 detail

but when I try:

print(forecast.to_string(index=False, header=False))

I get error:

AttributeError: 'tuple' object has no attribute 'to_string'
1 Answers

You can try with .values[0] with iloc:

forecast = ((predictions.iloc[5].values[0]), mape)

Or use unpacking by adding * before predictions.iloc[0]:

forecast = (*predictions.iloc[0], mape)

Then, you can simply print by:

print(*forecast, sep=' ')
Related