我用来pd.json_normalize将"sections"这些数据中的字段展平为行。除了空列表的行之外,它工作正常"sections"。
该 ID 被完全忽略,并且从最终的扁平化数据框中丢失。我需要确保数据中的每个唯一 ID 至少有一行(某些 ID 可能有很多行,每个唯一 ID、每个唯一 、section_id、question_id以及answer_id当我在数据中取消嵌套更多字段时最多可以有一行):
{'_id': '5f48f708fe22ca4d15fb3b55',
'created_at': '2020-08-28T12:22:32Z',
'sections': []}]
Run Code Online (Sandbox Code Playgroud)
样本数据:
sample = [{'_id': '5f48bee4c54cf6b5e8048274',
'created_at': '2020-08-28T08:23:00Z',
'sections': [{'comment': '',
'type_fail': None,
'answers': [{'comment': 'stuff',
'feedback': [],
'value': 10.0,
'answer_type': 'default',
'question_id': '5e59599c68369c24069630fd',
'answer_id': '5e595a7c3fbb70448b6ff935'},
{'comment': 'stuff',
'feedback': [],
'value': 10.0,
'answer_type': 'default',
'question_id': '5e598939cedcaf5b865ef99a',
'answer_id': '5e598939cedcaf5b865ef998'}],
'score': 20.0,
'passed': True,
'_id': '5e59599c68369c24069630fe',
'custom_fields': []},
{'comment': '',
'type_fail': None,
'answers': [{'comment': '', …Run Code Online (Sandbox Code Playgroud) 我每天有一些 Pandas 代码运行 9 个不同的文件。目前,我有一个计划任务在某个时间运行代码,但有时我们的客户端没有按时将文件上传到 SFTP,这意味着代码将失败。我想创建一个文件检查脚本。
如果 sqitch 中没有依赖项,是否可以恢复特定更改?例如,我像下面的代码一样设置我的项目并部署它并加载一些数据。大约一天后(或者可能是同一天),利益相关者决定我需要向 fct_tickets 添加更多列或对该表进行另一次更改。
如果我尝试恢复 fct_tickets,它将恢复所有后续表,这很遗憾,因为我已经向它们加载了数据。
我已经尝试了某些标志(--upon、--unto 等),但它仍然想恢复 sqitch.plan 文件中 fct_tickets 之后的所有内容。
sqitch add scm_example --template pg_create_schema -s schema=example -n 'Create schema for Example data.'
sqitch add fct_tickets --requires scm_example -n 'Create table for ticket data.'
sqitch add fct_chats --requires scm_example -n 'Create table for chat data.'
sqitch add fct_calls --requires scm_example -n 'Create table for call data.'
sqitch add dim_users --requires scm_example -n 'Create table for user mapping data.'
sqitch add dim_source_files --requires scm_example -n 'Create table to …Run Code Online (Sandbox Code Playgroud)