drogon/tests/index_batch_tests.py

107 lines
3.6 KiB
Python
Raw Normal View History

2018-12-23 18:30:11 +01:00
from analysis.market_snapshot import Market
from analysis.index_batch import IndexMM
import pandas as pd
sample_market = [
{'tamano_categorico': 'coche pequeño',
'tipo_anuncio': 1,
'precio': 15000,
'calle': 'B1',
'telefono': 123,
'latitud': 2.1,
'longitud': 1.2},
{'tamano_categorico': 'coche pequeño',
'tipo_anuncio': 1,
'precio': 20000,
'calle': 'B2',
'telefono': 321,
'latitud': 2.1,
'longitud': 1.2},
{'tamano_categorico': 'coche grande',
'tipo_anuncio': 1,
'precio': 20000,
'calle': 'B2',
'telefono': 321,
'latitud': 2.1,
'longitud': 1.2},
{'tamano_categorico': 'coche grande',
'tipo_anuncio': 1,
'precio': 25000,
'calle': 'B2',
'telefono': 123,
'latitud': 2.1,
'longitud': 1.2},
{'tamano_categorico': 'coche y moto',
'tipo_anuncio': 1,
'precio': 22000,
'calle': 'B1',
'telefono': 456,
'latitud': 2.1,
'longitud': 1.2},
{'tamano_categorico': 'coche y moto',
'tipo_anuncio': 1,
'precio': 26000,
'calle': 'B3',
'telefono': 789,
'latitud': 2.1,
'longitud': 1.2},
{'tamano_categorico': None,
'tipo_anuncio': 1,
'precio': 15000,
'calle': 'abc',
'telefono': 456,
'latitud': 2.1,
'longitud': 1.2},
{'tamano_categorico': 'moto',
'tipo_anuncio': 1,
'precio': 3000,
'calle': 'B4',
'telefono': 123,
'latitud': 2.1,
'longitud': 1.2},
{'tamano_categorico': '2 coches o más',
'tipo_anuncio': 1,
'precio': 60000,
'calle': 'B4',
'telefono': 123,
'latitud': 2.1,
'longitud': 1.2},
{'tamano_categorico': 'coche pequeño',
'tipo_anuncio': 1,
'precio': 20000,
'calle': 'B2',
'telefono': 321,
'latitud': 2.1,
'longitud': 1.2},
{'tamano_categorico': 'coche pequeño',
'tipo_anuncio': 2,
'precio': 50,
'calle': 'B4',
'telefono': 123,
'latitud': 2.1,
'longitud': 1.2},
{'tamano_categorico': 'moto',
'tipo_anuncio': 1,
'precio': 300000,
'calle': 'B4',
'telefono': 123,
'latitud': 2.1,
'longitud': 1.2}
]
date_range = {'start': '2018-01-01 00:00:00',
'end': '2018-02-01 00:00:00'}
market = Market()
market.load_market(sample_market,
date_range=date_range)
market.market.fillna(value=pd.np.nan, inplace=True)
print(market.market.to_string())
market.clean_market('index')
print(market.market.to_string())
index = IndexMM()
index.calculate(market)
index.get_data()