0
点赞
收藏
分享

微信扫一扫

data list dict toDf

data = [{"a": 1, "b": 2}, {"a": 3, "b": 4}]
data = {"a": [1, 3], "b": [2, 4]}  # 键值必须用list

import pandas as pd
df = pd.DataFrame(data)
print(df)

not "a" in ["a", "b"]
"a" not in ["a", "b"]

The expressions not "a" in ["a", "b"] and "a" not in ["a", "b"] are equivalent and both evaluate to False. They check whether the string "a" is not present in the list ["a", "b"]. Since "a" is indeed in the list, the result is False.
表达式 not "a" in ["a", "b"]"a" not in ["a", "b"] 是等效的,并且都计算为 False 。他们检查字符串 "a" 是否不存在于列表 ["a", "b"] 中。由于 "a" 确实在列表中,因此结果是 False

In Python, the not in operator negates the result of the in operator. So, both expressions are logically the same and return False because "a" is part of the list.
在 Python 中, not in 运算符对 in 运算符的结果求反。因此,两个表达式在逻辑上是相同的,并且返回 False ,因为 "a" 是列表的一部分。

The expressions not "a" in "ab" and "a" not in "ab" are equivalent in Python, both checking whether the character "a" is not present in the string "ab". The result for both expressions is False. This means that the character "a" is in the string "ab".
表达式 not "a" in "ab""a" not in "ab" 在 Python 中是等效的,都检查字符 "a" 是否不存在于字符串 "ab" 中。两个表达式的结果都是 False 。这意味着字符 "a" 位于字符串 "ab" 中。

举报

相关推荐

0 条评论