小编Dmi*_*nov的帖子

对pandas数据帧的列进行排序

Out[1015]: gp2
department  MOBILE      QA      TA     WEB MOBILE     QA     TA    WEB
           minutes minutes minutes minutes growth growth growth growth
period                                                                
2016-12-24     NaN     NaN   140.0   400.0    NaN    NaN    0.0  260.0
2016-12-25     NaN     NaN     NaN    80.0    NaN    NaN    NaN -320.0
2016-12-26     NaN     NaN     NaN    20.0    NaN    NaN    NaN  -60.0
2016-12-27     NaN    45.0     NaN   180.0    NaN   25.0    NaN  135.0
2016-12-28   600.0     NaN     NaN    15.0  420.0    NaN    NaN -585.0
...            ...     ...     ...     ...    ...    ...    ...    ...
2017-01-03     NaN     NaN     NaN    80.0    NaN …
Run Code Online (Sandbox Code Playgroud)

python sorting dataframe pandas

2
推荐指数
1
解决办法
52
查看次数

pandas数据框:将2列(值,值)转换为2列(值,类型)

假设我有以下数据框“ A”

         utilization  utilization_billable
service                                   
1               10.0                   5.0
2               30.0                  20.0
3               40.0                  30.0
4               40.0                  32.0
Run Code Online (Sandbox Code Playgroud)

我需要将其转换为以下数据框“ B”

         utilization      type
service                       
1               10.0     total
2               30.0     total
3               40.0     total
4               40.0     total
1                5.0  billable
2               20.0  billable
3               30.0  billable
4               32.0  billable
Run Code Online (Sandbox Code Playgroud)

因此,来自第一个的值将被归类为类型列,其值是total或billable。

data = {
    'utilization': [10.0, 30.0, 40.0, 40.0],
    'utilization_billable': [5.0, 20.0, 30.0, 32.0],
    'service': [1, 2, 3, 4]
}
df = pd.DataFrame.from_dict(data).set_index('service')
print(df)

data = {
    'utilization': [10.0, 30.0, …
Run Code Online (Sandbox Code Playgroud)

python pandas

2
推荐指数
1
解决办法
42
查看次数

Terraform 不断强制重新创建资源(删除然后创建)

我正在使用 terraform + terraform cloud (用于远程状态管理)

\n\n
\xe2\x9c\xa6 \xe2\x9e\x9c terraform -v                               \nTerraform v0.12.24\n+ provider.aws v2.60.0\n+ provider.null v2.1.2\n\n
Run Code Online (Sandbox Code Playgroud)\n\n
\xe2\x9c\xa6 \xe2\x9e\x9c terraform plan                                     \nRefreshing Terraform state in-memory prior to plan...\nThe refreshed state will be used to calculate this plan, but will not be\npersisted to local or remote state storage.\n\nmodule.vpc.module.vpc.aws_vpc.this[0]: Refreshing state... [id=vpc-0e89e6d2515004e3d]\nmodule.s3.aws_s3_bucket.project_bucket: Refreshing state... [id=project-bucket]\ndata.aws_availability_zones.all: Refreshing state...\nmodule.bastion.aws_key_pair.ssh_key: Refreshing state... [id=project]\nmodule.vpc.module.vpc.aws_eip.nat[0]: Refreshing state... [id=eipalloc-053796962073bcc33]\nmodule.vpc.module.vpc.aws_subnet.private[1]: Refreshing state... [id=subnet-037152cf7128a8a31]\nmodule.vpc.module.vpc.aws_subnet.private[0]: Refreshing state... [id=subnet-0b4f07b30fb51ab78]\nmodule.vpc.module.vpc.aws_route_table.private[0]: Refreshing state... [id=rtb-0dd52f77a6da2f2b8]\nmodule.vpc.module.vpc.aws_subnet.private[2]: Refreshing state... [id=subnet-007658ad3ec49fed8]\nmodule.vpc.module.vpc.aws_route_table.public[0]: Refreshing state... [id=rtb-050f67e4a3f5b978e]\nmodule.vpc.module.vpc.aws_subnet.public[1]: Refreshing state... [id=subnet-03b773348ee69e0ec]\nmodule.vpc.module.vpc.aws_subnet.public[2]: …
Run Code Online (Sandbox Code Playgroud)

terraform terraform-provider-aws terraform0.12+

2
推荐指数
1
解决办法
6959
查看次数

s6 覆盖 s6-svc 主管未监听

root@0cd6bfb7e363 app]# s6-svc /etc/services.d/uwsgi/
s6-svc: fatal: unable to control /etc/services.d/uwsgi/: supervisor not listening

[root@0cd6bfb7e363 app]# s6-svc -r /etc/services.d/uwsgi/
s6-svc: fatal: unable to control /etc/services.d/uwsgi/: supervisor not listening

Run Code Online (Sandbox Code Playgroud)

然而

[root@0cd6bfb7e363 app]# ps aufx
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.0  0.0    204     4 pts/0    Ss   01:42   0:00 s6-svscan -t0 /var/run/s6/services
root          30  0.0  0.0    188     8 pts/0    S    01:42   0:00 foreground  if   /etc/s6/init/init-stage2-redirfd   foreground    if     if      s6-echo      -n      --
root          40  0.0  0.0    184 …
Run Code Online (Sandbox Code Playgroud)

s6

2
推荐指数
1
解决办法
2923
查看次数

aws eks 和 aws sso RBAC 身份验证问题

我创建了一个新的 AWS SSO(使用内部 IDP 作为身份源,因此不使用 Active Directory)。
我能够登录 AWS CLI、AWS GUI,但无法执行任何 kubectl 操作。

error: You must be logged in to the server (Unauthorized)
Run Code Online (Sandbox Code Playgroud)

我认为这与 RBAC 有关,因为我可以通过 aws eks get-token.

? cat ~/.aws/config

[profile team-sso-admin]
sso_start_url=https://team.awsapps.com/start
sso_region=us-west-2
sso_account_id=1111111111
sso_role_name=AdministratorAccess
region=us-west-2
credential_process = aws-vault exec team-sso-admin --json


? aws-vault exec team-sso-admin --debug -- zsh --login
? env | grep AWS
AWS_VAULT_PROMPT=pass
AWS_VAULT_BACKEND=pass
AWS_VAULT=team-sso-admin
AWS_DEFAULT_REGION=us-west-2
AWS_REGION=us-west-2
AWS_ACCESS_KEY_ID=xxx
AWS_SECRET_ACCESS_KEY=xxx
AWS_SESSION_TOKEN=xxx
AWS_SECURITY_TOKEN=yyy
AWS_SESSION_EXPIRATION=2021-01-11T05:55:51Z
AWS_SDK_LOAD_CONFIG=1

? aws sts get-caller-identity --output yaml 

Account: '111111111111' …
Run Code Online (Sandbox Code Playgroud)

kubernetes amazon-eks aws-sso kubernetes-rbac

2
推荐指数
2
解决办法
1650
查看次数

zsh 条件 OR 失败

# delete git branch
git--() {

  BRANCH=$1

  if [ -n $BRANCH]; then
    BRANCH=$(git rev-parse --abbrev-ref HEAD)
  fi

  if [ "$BRANCH" = 'master' || "$BRANCH" = 'develop' ]; then

    red "You should not delete $BRANCH"
    return 0
  fi
}
Run Code Online (Sandbox Code Playgroud)

失败了

git--:[:8: ']' expected
zsh: master: command not found...
git--:8: command not found: master
No branch specified therefore I'm using the current one: master
On branch master
nothing to commit, working tree clean
Do you really want to delete the branch master …
Run Code Online (Sandbox Code Playgroud)

zsh

1
推荐指数
1
解决办法
7885
查看次数

如何获取调用函数的可点击文本

假设我在缓冲区中有以下文本

CMM-3:       Description
CMM-91:      Description 2
Run Code Online (Sandbox Code Playgroud)

我希望CMM-XX成为调用自定义功能的可点击区域

(defun jira-ticket-view (&optional jira-ticket)
  "Open Jira Ticket Inside Emacs"
  (interactive)
  ....)
Run Code Online (Sandbox Code Playgroud)

如何在emacs / elisp中实现?

emacs button

1
推荐指数
1
解决办法
50
查看次数

kubernetes pod 和气流工作日志的 DNS

\xe2\x9e\x9c k get pods -n edna    \nNAME                              READY   STATUS    RESTARTS   AGE\nairflow-79d5f59644-dd4k7          1/1     Running   0          16h\nairflow-worker-67bcf7844b-rq7r8   1/1     Running   0          22h\nbackend-65bcb6546-wvvqj           1/1     Running   0          2d16h\n\n
Run Code Online (Sandbox Code Playgroud)\n

因此,在airflow-79d5f59644-dd4k7 pod中运行的气流正在尝试从气流工作人员(celery/python,运行一个基于烧瓶的简单Web服务器处理日志)中提取日志,但它不能,因为域名airflow-worker-67bcf7844b- rq7r8未在airflow-79d5f59644-dd4k7内解析

\n
*** Log file does not exist: /usr/local/airflow/logs/hello_world/hello_task/2020-07-14T22:05:12.123747+00:00/1.log\n*** Fetching from: http://airflow-worker-67bcf7844b-rq7r8:8793/log/hello_world/hello_task/2020-07-14T22:05:12.123747+00:00/1.log\n*** Failed to fetch log file from worker. HTTPConnectionPool(host=\'airflow-worker-67bcf7844b-rq7r8\', port=8793): Max retries exceeded with url: /log/hello_world/hello_task/2020-07-14T22:05:12.123747+00:00/1.log (Caused by NewConnectionError(\'<urllib3.connection.HTTPConnection object at 0x7fd37d6a9790>: Failed to establish a new connection: [Errno -2] Name or service not known\'))\n\n
Run Code Online (Sandbox Code Playgroud)\n

我怎样才能做到这一点?

\n

我知道 Airflow …

kubernetes airflow kubernetes-dns

1
推荐指数
1
解决办法
2251
查看次数

节点导出器未在集群的 3 个节点上运行

我在 AWS EKS 中将节点导出器作为守护程序集运行,今天发现它存在于 10 个节点上,但我的集群有 13 个节点。

如何确保它也在 3 个丢失的节点上运行?

kubernetes prometheus prometheus-node-exporter

1
推荐指数
1
解决办法
1350
查看次数

奇怪的ES6 Array.every行为

[,'a'].every(x => x==='a') 
> True
Run Code Online (Sandbox Code Playgroud)

返回True,虽然第一项是'undefined',因此应该为False?

[,'a'].map(x => x) 
> [undefined × 1, "a"]
Run Code Online (Sandbox Code Playgroud)

javascript arrays ecmascript-6

0
推荐指数
1
解决办法
51
查看次数

ZSH 仅循环数组的第一项

#/bin/zsh
servers=('10.138.0.8' '10.138.0.91')

for srv in $servers; do
   echo "Checking health for " $srv
   echo "=========================================="
   echo mntr | nc $srv 2181 
done
Run Code Online (Sandbox Code Playgroud)

当我执行时,我没有循环第二个值10.138.0.91,如下所示

[devops@devops]~% ./healthcheck/zookeeper.sh  
Checking health for  10.138.0.8
==========================================
zk_version      3.4.10-39d3a4f269333c922ed3db283be479f9deacaa0f, built on 03/23/2017 10:13 GMT
zk_avg_latency  0
zk_max_latency  0
zk_min_latency  0
zk_packets_received     9
zk_packets_sent 8
zk_num_alive_connections        1
zk_outstanding_requests 0
zk_server_state follower
zk_znode_count  4
zk_watch_count  0
zk_ephemerals_count     0
zk_approximate_data_size        27
zk_open_file_descriptor_count   28
zk_max_file_descriptor_count    4096
Run Code Online (Sandbox Code Playgroud)

为什么?

unix shell scripting zsh shebang

0
推荐指数
1
解决办法
559
查看次数

Terraform - 无法使用 terraform-aws-modules/security-group/aws 定义安全组

我正在尝试此模块中的示例 https://registry.terraform.io/modules/terraform-aws-modules/security-group/aws/3.10.0

主要.tf:

module "vpc" {
  source = "terraform-aws-modules/vpc/aws"

  name = "${var.environment}-project-vpc"
  cidr = "10.0.0.0/16"

  #
  # Important!
  # https://github.com/terraform-aws-modules/terraform-aws-vpc/issues/403
  # Only append or delete from the end of the list
  #
  azs             = ["us-east-2a", "us-east-2b", "us-east-2c"]
  private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
  public_subnets  = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]

  enable_nat_gateway     = true
  single_nat_gateway     = true
  one_nat_gateway_per_az = false

  enable_dns_hostnames = true
  enable_dns_support   = true

  tags = module.project_config.tags
}


module "bastion_sg" {
  source = "terraform-aws-modules/security-group/aws"

  name        = "bastion-service"
  description = "Security group for …
Run Code Online (Sandbox Code Playgroud)

terraform terraform-provider-aws terraform0.12+ terraform-aws-modules

0
推荐指数
1
解决办法
2271
查看次数

在 prometheus Alertmanager 通知中提及 slack 用户

所以我有一个通用标签opsteam,一旦 Alertmanager 被解雇,它应该让 DM 处于松弛状态。然而,在 slack 中,我得到的用户名是纯文本,没有突出显示,并且这些用户没有收到任何消息。

nodeSelector: 
  prometheus: "true"
enabled: true
retention: "30d"
extraFlags:
  - web.enable-lifecycle
  - web.enable-admin-api
strategy:
  type: RollingUpdate
global:
  scrape_interval: 30s
  external_labels:
    env: prod
    client: client
    cluster: project-prod-eks
    opsteam: "@U0325FRAD @U01GN7KJHU"
Run Code Online (Sandbox Code Playgroud)

如果我更改opsteam: "@U0325FRAD @U01GN7KJHU"opsteam: "@john @jim"它也没有效果。

所以这是我的自定义松弛通知

nodeSelector: 
  prometheus: "true"
enabled: true
retention: "30d"
extraFlags:
  - web.enable-lifecycle
  - web.enable-admin-api
strategy:
  type: RollingUpdate
global:
  scrape_interval: 30s
  external_labels:
    env: prod
    client: client
    cluster: project-prod-eks
    opsteam: "@U0325FRAD @U01GN7KJHU"
Run Code Online (Sandbox Code Playgroud)

是的,我的消息只是松弛的文本。

prometheus slack prometheus-alertmanager

0
推荐指数
1
解决办法
2018
查看次数