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 = [
|
2020-11-03 07:29:17 +01:00
|
|
|
{
|
|
|
|
|
"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"}
|
2018-12-23 18:30:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
market = Market()
|
2020-11-03 07:29:17 +01:00
|
|
|
market.load_market(sample_market, date_range=date_range)
|
2018-12-23 18:30:11 +01:00
|
|
|
market.market.fillna(value=pd.np.nan, inplace=True)
|
|
|
|
|
print(market.market.to_string())
|
2020-11-03 07:29:17 +01:00
|
|
|
market.clean_market("index")
|
2018-12-23 18:30:11 +01:00
|
|
|
print(market.market.to_string())
|
|
|
|
|
|
|
|
|
|
index = IndexMM()
|
|
|
|
|
index.calculate(market)
|
|
|
|
|
index.get_data()
|