【问题标题】:How can I make a Venn diagram in Python of two lists of values 0 and 1 and get the intersection where both values are 1?如何在 Python 中制作两个值 0 和 1 列表的维恩图,并获得两个值均为 1 的交集?
【发布时间】:2022-12-01 17:46:51
【问题描述】:

我有两个长度相同的 0 和 1 列表:例如a = [0,0,0,1,1,0,1], b = [0,1,0,1,0,1,1] 并希望得到一个维恩图,其交集为都是 1 的值,所以在这种情况下,2 个值在同一位置将是 1。 我怎样才能做到这一点?

提前致谢!

我尝试了类似 venn2(subsets = df['a']==1, df['b']==1, set_labels = ('a', 'b'), alpha = 0.5)

但它没有用。

【问题讨论】:

    标签: python venn


    【解决方案1】:
    a = [0,0,0,1,1,0,1]
    b = [0,1,0,1,0,1,1]
    
    result = list(x and y for x, y in zip(a, b))
    
    print(result)
    # result = [0, 0, 0, 1, 0, 0, 1]
    

    【讨论】:

      猜你喜欢
      • 2023-01-19
      • 1970-01-01
      • 1970-01-01
      • 2020-05-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-20
      相关资源
      最近更新 更多