0
I have the following list of pandas
The objective of the program is to obtain the degree of similarity according to the entered data. in this case it is a program to query houses, and I have already done to consult houses with the same data that the user indicates, but in case the user indicates not to exist in the database the objective is to appear similar houses ...
to consult the houses with the same variables I used this code
lista = ListaCompleta[ListaCompleta.Concelho.isin(concelhos) & (ListaCompleta['Tipo Imovel'] == tipo_imv) &
(ListaCompleta['Estado'] == estad) & (ListaCompleta['Quartos'] == quar) &
ListaCompleta.Preco.notnull()]
but if what the user inserts does not exist in the database, I want to create a new column where you enter a value between 0 and 1 where 1 is exactly the same and 0 is not the same (for each row)
To calculate the similarity of each column of each row, I thought to use this code (I do not know if it is the best)
(the variables "Quart", "casa_banh", "area", "garag", "year" are entered by the user)
similar_quartos = (quart-ListaCompleta['Quartos'])/5
similar_casa_banho = (casa_banh-ListaCompleta['Casa Banho'])/3
similar_area = (area-ListaCompleta['Area'])/200
similar_garagem = (garag-ListaCompleta['Garagem'])/3
similar_ano = (ano-ListaCompleta['Ano'])/30
but then I need to add to the list, I tried this code, but it’s not giving
lista['similiariedade'] = lista[(similar_quartos+similar_casa_banho+similar_area+similar_garagem+similar_ano)/5]
and create a column with a value of 0 to 1 in each row of the list, to know which home is more similar to the one the user entered
is giving me the following error: ufunc 'subtract' Did not contain a loop with Signature matching types dtype('<U21') dtype('<U21') dtype('<U21')')
– Tiago Fernandes
This error occurs when trying to perform operations (+ or -) with integers and string, such as
pd.Series(['abc', 'def']) - pd.Series([1, 2])
. Can you give me more information about when the error occurs?– AlexCiuffa
I was already able to solve, for some reason in the for cycle I was putting the column variable as string type, so it was an error, and I also used pd.to_numeric() to put everything numerical in Else so it didn’t give shit
– Tiago Fernandes