I’m trying to make a custom search filter with SQLite, pandas, and multi-select widget. in my scenario when the user searches for an item in the search box that item’s text-input has to stored in a multi-select widget. while we go on searching and that search input data is going on appending to a list that connects with multi-select. I had done it but in the end, I got the error
TypeError: unhashable type: ‘list’
. can anyone tell me what was the error in my code?
import streamlit as st
import pandas as pd
import time
import sqlite3conn = sqlite3.connect(‘search.db’)
c = conn.cursor()def create_table():
c.execute(‘CREATE TABLE IF NOT EXISTS serach_filter(main_search varchar(20) )’)def add_data(main_search):
c.execute(‘INSERT INTO serach_filter(main_search) VALUES (?)’, [main_search])
conn.commit()def data_list():
c.execute(‘SELECT * FROM serach_filter’)
data = c.fetchall()
final_data = [list(i) for i in data]
list_df = pd.DataFrame(final_data, columns=[‘search’])
print(“new DataFrame”)
print(list_df)
return list_df[‘search’]df = pd.read_csv(“clusterised pricerunner_aggregate.csv”)
def delete_task():
c.execute(‘DELETE FROM serach_filter’)
data = c.fetchall()def main():
new_user = st.text_input(“main_search”)
if st.button(“search”):
create_table()
add_data(new_user)user_result = data_list() multiselct_filter = st.multiselect("custom filter", user_result) if st.button("apply"): data_columns = df['Product_Title', 'Cluster_Label', 'Category_Label'] main_result = df[(data_columns.isin(user_result))] st.dataframe(main_result) elif st.button("erase"): delete_task()
if name == ‘main’:
main()