答案 0 :(得分:1)
当我们使用Azure Log Analytics REST API进行查询时,我们需要使用print (df)
data Flag Set
0 0 True A
1 8 True A
2 30 True A
3 -1 False A
4 -14 False A
5 20 True B
6 5 False B
7 19 False B
8 7 False C
9 8 False c
df1 = pd.crosstab(df['Set'], df['Flag'])
d = df1[df1.ne(0).all(axis=1)].min(axis=1).to_dict()
print (d)
{'A': 2, 'B': 1}
df1 = (df[df['Set'].isin(d.keys())]
.groupby(['Set', 'Flag'], group_keys=False)
.apply(lambda x: x.head(d[x.name[0]])))
print (df1)
data Flag Set
3 -1 False A
4 -14 False A
0 0 True A
1 8 True A
6 5 False B
5 20 True B
作为请求标头。有关更多详细信息,请参阅here。
例如
注册Azure AD应用程序
将AAD应用程序访问权限授予我们的Log Analytics工作区。请为AD应用程序分配Authorization=Bearer eyJ....
角色
获取访问令牌
Log Analytics Reader
POST /<your tenant id>/oauth2/token HTTP/1.1
Host: login.microsoftonline.com
Content-Type: application/x-www-form-urlencoded
grant_type =client_credentials
&client_id=<>
&client_secret=<>
&resource=https://westus2.api.loganalytics.io