Tilde sign in python dataframe

前端 未结 3 933
时光说笑
时光说笑 2020-12-16 09:22

Im new to python and came across a code snippet.

df = df[~df[\'InvoiceNo\'].str.contains(\'C\')]

Would be much obliged if I could know what

3条回答
  •  长情又很酷
    2020-12-16 09:54

    if you want to apply it to all columns in a data frame you can use

    df.any(axis=1)
    df = df[~(df>0).any(axis=1)]
    

    This checks if val > 0 in all columns of the data frame and returns a Boolean. Likewise, axis=0 is for index/row wise.

提交回复
热议问题