how can i return all the variables to to_html() at once?

40 Views Asked by At
   def upload_file():
    if request.method == 'POST':
        print(request.files['file'])
        f = request.files['file']
        data_xls = pd.read_excel(f)
        df2 = data_xls.reset_index()
        p = df2.dropna(axis=1 , how='all')
        name_filter = df2[df2['Pensioner Name'].astype(str).str.match('^[a-zA-Z\s\.]*$')]      
        cnic_filter = df2[df2['CNIC'].astype(str).str.match('^[\'][0-9+]{5}-[0-9+]{7}-[0-9]{1}[\']$')]
        wallet_filter = df2[df2['Wallet Account No'].astype(str).str.contains('^[0-9+]{8}$')]
        mobile_filter = df2[df2['Mobile Number'].astype(str).str.contains('^[3+][0-9+]{9}$')]

        filterf = df2[[name_filter , cnic_filter, wallet_filter,  mobile_filter]]
        filterf = pd.DataFrame(filterf)
        return filterf.to_html()

I am trying this but getting an error

ValueError: cannot copy sequence with size 62 to array axis with dimension 11

Please help i am new to pandas

1

There are 1 best solutions below

1
On

I would parse it to JSON or XML.

It is easy to handle both in Python (https://www.w3schools.com/python/python_json.asp) and JS/PHP/Whatever.