Formatting.

This commit is contained in:
pablo 2020-11-03 07:29:17 +01:00
parent cd9c3b6e39
commit a79fc533ee
11 changed files with 231 additions and 204 deletions

View file

@ -3,104 +3,125 @@ 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'}
{
"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.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')
market.clean_market("index")
print(market.market.to_string())
index = IndexMM()
index.calculate(market)
index.get_data()