作者热门文章
- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我是 python/pandas 的新手,遇到了一个代码片段。
df = df[~df['InvoiceNo'].str.contains('C')]
如果我能知道波浪号在这种情况下的用法,我会非常感激吗?
最佳答案
这意味着按位不,反转 bool 掩码 - False
s 到 True
s 和 True
s 到 False
秒。
示例:
df = pd.DataFrame({'InvoiceNo': ['aaC','ff','lC'],
'a':[1,2,5]})
print (df)
InvoiceNo a
0 aaC 1
1 ff 2
2 lC 5
#check if column contains C
print (df['InvoiceNo'].str.contains('C'))
0 True
1 False
2 True
Name: InvoiceNo, dtype: bool
#inversing mask
print (~df['InvoiceNo'].str.contains('C'))
0 False
1 True
2 False
Name: InvoiceNo, dtype: bool
按 boolean indexing
过滤:
df = df[~df['InvoiceNo'].str.contains('C')]
print (df)
InvoiceNo a
1 ff 2
所以输出的是DataFrame的所有行,在InvoiceNo
列中不包含C
。
关于python - 波浪号登录 Pandas 数据框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46054318/
我目前正在开发一个具有模块化设计的网站,其中包含文本模块、图像模块、2 列模块......用户可以根据需要添加/删除/重新排序它们。 每个模块都有一个波浪形/flex 的边框: 有没有可能用css做这
我正在尝试在网站上创建波浪效果 like this其中有一个主色波(深紫色),然后是沿边缘的浅色波。我已尝试使用 CSS position 和 top 定位多个路径,但无法使它们工作。 这是我的基本波
如何在透明图像背景上构建波浪? 布局图像: 我需要白色顶部背景中的波浪。 最佳答案 我稍微改进了 akshay 的回答版本。这包括两个单独的选项。 选项 1 如果不需要保留宽高比,则曲线将随宽度变化。
我是一名优秀的程序员,十分优秀!