【问题标题】:how can i return all the variables to to_html() at once? [duplicate]如何一次将所有变量返回到 to_html()? [复制]
【发布时间】:2020-01-21 18:06:38
【问题描述】:
   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()

我正在尝试,但出现错误

ValueError: 无法将大小为 62 的序列复制到维度为 11 的数组轴

请帮助我是熊猫的新手

【问题讨论】:

    标签: python regex pandas text-to-html


    【解决方案1】:

    我会将其解析为 JSON 或 XML。

    在 Python (https://www.w3schools.com/python/python_json.asp) 和 JS/PHP/Whatever 中都可以轻松处理。

    【讨论】:

    • 请您添加一个代码 sn-p 将此代码编辑为您想要的内容
    猜你喜欢
    • 2020-05-06
    • 1970-01-01
    • 2016-10-24
    • 2018-12-04
    • 2015-06-14
    • 1970-01-01
    • 1970-01-01
    • 2014-11-22
    • 1970-01-01
    相关资源
    最近更新 更多