私信  •  关注

Florian Bernard

Florian Bernard 最近创建的主题
Florian Bernard 最近回复了
5 年前
回复了 Florian Bernard 创建的主题 » 如何从Python中此对象返回的字典访问特定值

这样地。

infos = [[0, 'virtual_94', {'sequence': 10, 'display_type': False, 'product_uom_qty': 1, 'qty_delivered_manual': 0, 'price_unit': 1000, 'discount': 0, 'customer_lead': 0, 'product_id': 1, 'product_no_variant_attribute_value_ids': [[6, False, []]], 'name': 'Produto de teste', 'product_uom': 1, 'analytic_tag_ids': [[6, False, []]], 'route_id': False, 'tax_id': [[6, False, [1]]], 'sale_line_exemption_id': False}]]

ID = infos[0][2]["tax_id"][0][2][0]
6 年前
回复了 Florian Bernard 创建的主题 » 将多个.txt文件作为数据帧加载到python中

你可以这样做。


from collections import defaultdict
from pathlib import Path
import pandas as df

my_dir_path = "/parh/to/folder"

results = defaultdict(list)
for file in Path(my_dir_path).iterdir():
    with open(file, "r") as file_open:
        results["file_name"] = file.name
        results["text"].append(file_open.read())
df = pd.DataFrame(results)