0

I have an 200 rows in Pandas Serias all_data['close'] and need to compare few last rows with m_a last rows. Here's my code:

import pandas as pd
from talib import SMA

all_data = pd.DataFrame({
    'open': [item[1] for item in data],
    'close': [item[4] for item in data],
})

m_a = SMA(all_data['close'], timeperiod=5)

From here I need to find a way how to compare values from all_data['close'] and m_a. I tried this way:

print(m_a[-1:])

But I only can get this value:

199   0.00001103  
dtype: float64

I need that number - 0.00001103, so if I make something like this

print(m_a[-1:].item())

I get a value like this 1.1027070707070725e-05 and it's not what I'm looking for.

trotta
  • 1,232
  • 1
  • 16
  • 23
Ksanoni
  • 1
  • 1
  • 1.1027070707070725e-05 = 0.00001103 – Nihal Mar 12 '19 at 13:12
  • `print("{:.10f}".format(m_a[-1:].item()))` - replacing 10 with whatever level of precision you want to display. – Toby Petty Mar 12 '19 at 13:13
  • This is called scientific notation. Didn't try it myself but maybe the answer to [this](https://stackoverflow.com/questions/21137150/format-suppress-scientific-notation-from-python-pandas-aggregation-results) question is helpful? It basically says that you can change the settings in pandas to surpress scientific notation like this: `pd.set_option('display.float_format', lambda x: '%.3f' % x)` – trotta Mar 12 '19 at 13:18
  • @Nihal thank you, that's the trick. So I can easily compare it by indexes. – Ksanoni Mar 12 '19 at 13:43

0 Answers0