@Query("SELECT count(*) as count FROM #{#n1ql.bucket} WHERE #{#n1ql.filter} ")
long myCount();
我当前的数据框结果
import pandas as pd
import os
list_of_dict2 = [[{'1580674': ['HA-567034786', 'AB-1018724']}], [{'1554970': ['AB-6348403', 'HA-7298656']}, {'1554970': ['AB-2060953', 'HA-990228']}, {'1554970': ['HA-7287204', 'AB-1092380','GR-33333']}]]
list_of_dict = []
for i in list_of_dict2:
for j in i:
list_of_dict.append(list(j.values())[0])
df = pd.DataFrame(list_of_dict)
print(df)
使用字典列表,我可以使用下面的代码生成数据框。但是我的问题是我有一些 使其很多词典列表出现问题。让我解释一下我想要实现的目标。
例如,对于数据帧的每一行,我想使它成为多对多字典,并且在列表上具有多个值。说,最后一个索引3 我要像下面这样
预期输出:(用于第二个索引)
0 1 2
0 HA-567034786 AB-1018724 None
1 AB-6348403 HA-7298656 None
2 AB-2060953 HA-990228 None
3 HA-7287204 AB-1092380 GR-33333
预期输出:(用于第三个索引)
{
"AB-2060953" : ['HA-990228'],
"HA-990228" : ['AB-2060953']
}
答案 0 :(得分:1)
一种方法可能是:
import 'package:flutter/material.dart';
void main() {
runApp(MyTabs());
}
class MyTabs extends StatefulWidget {
@override
MyTabsState createState() => MyTabsState();
}
class MyTabsState extends State<MyTabs> with SingleTickerProviderStateMixin {
TabController controller;
Color currentTabColor;
@override
void initState() {
super.initState();
currentTabColor = Colors.red;
controller = TabController(vsync: this, length: 3);
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
primaryColor: currentTabColor,
),
home: Scaffold(
appBar: AppBar(
title: Text('Multi Colored Tab Bar'),
bottom: TabBar(
onTap: (tabIndex) {
if (tabIndex == 0)
currentTabColor = Colors.red;
else if (tabIndex == 1)
currentTabColor = Colors.blue;
else
currentTabColor = Colors.green;
setState(() {
currentTabColor = currentTabColor;
});
},
controller: controller,
tabs: <Tab>[
Tab(
text: 'First Tab',
),
Tab(text: 'Second Tab'),
Tab(text: 'Third Tab'),
],
),
),
body: TabBarView(
controller: controller,
children: <Widget>[
Scaffold(backgroundColor: Colors.red),
Scaffold(backgroundColor: Colors.blue),
Scaffold(backgroundColor: Colors.green),
],
),
),
);
}
}
或者,在不假设唯一性且不处理集合的情况下,
def make_dict(row):
s = set(row[~row.isna()])
return {x: list(s - {x}) for x in s}
df.apply(make_dict, axis=1)
# Output:
0 {'AB-1018724': ['HA-567034786'], 'HA-567034786': ['AB-1018724']}
1 {'AB-6348403': ['HA-7298656'], 'HA-7298656': ['AB-6348403']}
2 {'HA-990228': ['AB-2060953'], 'AB-2060953': ['HA-990228']}
3 {'GR-33333': ['AB-1092380', 'HA-7287204'], 'AB-1092380': ['GR-33333', 'HA-7287204'], 'HA-7287204': ['GR-33333', 'AB-1092380']}
dtype: object