小编Pal*_*shi的帖子

在pandas数据帧中对列重复进行分组

现在有很多类似的问题,但大多数都回答了如何删除重复的列.但是,我想知道如何创建元组列表,其中每个元组包含重复列的列名.我假设每列都有一个唯一的名称.只是为了进一步说明我的问题:

df = pd.DataFrame({'A': [1, 2, 3, 4, 5],'B': [2, 4, 2, 1, 9],
                   'C': [1, 2, 3, 4, 5],'D': [2, 4, 2, 1, 9],
                   'E': [3, 4, 2, 1, 2],'F': [1, 1, 1, 1, 1]},
                   index = ['a1', 'a2', 'a3', 'a4', 'a5'])
Run Code Online (Sandbox Code Playgroud)

然后我想要输出:

[('A', 'C'), ('B', 'D')]
Run Code Online (Sandbox Code Playgroud)

如果你今天感觉很棒,那么也可以将相同的问题扩展到行.如何获取每个元组包含重复行的元组列表.

python numpy duplicates dataframe pandas

16
推荐指数
3
解决办法
1555
查看次数

Github Actions下构建作业时如何安装本地python包?

我正在构建一个 python 项目—— potion. 我想在将新分支合并到 master 之前使用 Github 操作来自动执行一些 linting 和测试。

为此,我使用了对 Github 推荐的 python actions 启动工作流程——Python Application的轻微修改。

在作业中的“安装依赖项”步骤中,我收到错误。这是因为 pip 尝试安装我的本地软件包potion但失败。

失败的代码if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

对应的错误是:

ERROR: git+https@github.com:<github_username>/potion.git@82210990ac6190306ab1183d5e5b9962545f7714#egg=potion is not a valid editable requirement. It should either be a path to a local project or a VCS URL (beginning with bzr+http, bzr+https, bzr+ssh, bzr+sftp, bzr+ftp, bzr+lp, bzr+file, git+http, git+https, git+ssh, git+git, git+file, hg+file, hg+http, hg+https, hg+ssh, hg+static-http, svn+ssh, …
Run Code Online (Sandbox Code Playgroud)

python pip github requirements.txt github-actions

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