Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python中关于重新索引布尔系列键的用户警告_Python_Pandas - Fatal编程技术网

Python中关于重新索引布尔系列键的用户警告

Python中关于重新索引布尔系列键的用户警告,python,pandas,Python,Pandas,当我使用索引访问pandas.DataFrame时,它给出了一个userswarmings,并且它们不会干扰它的输出。我希望知道这个用户警告是如何发生的,我应该如何避免这些用户警告?谢谢大家的关注 df = pandas.DataFrame([[k, ass4Dict[k], k[:2], k[-2:]] for k in ass4Dict]) df.columns = ['string', 'count', 'lstr', 'rstr'] df = df[df['count'] >= 1

当我使用索引访问pandas.DataFrame时,它给出了一个userswarmings,并且它们不会干扰它的输出。我希望知道这个用户警告是如何发生的,我应该如何避免这些用户警告?谢谢大家的关注

df = pandas.DataFrame([[k, ass4Dict[k], k[:2], k[-2:]] for k in ass4Dict])
df.columns = ['string', 'count', 'lstr', 'rstr']
df = df[df['count'] >= 10]
**df = df[df['lstr'].map(lambda x:x in gram2Dict)][df['rstr'].map(lambda x:x in gram2Dict)]**
df['lstrCNT'] = df['lstr'].map(lambda x: float(gram2Dict[x]))
df['rstrCNT'] = df['rstr'].map(lambda x: float(gram2Dict[x]))
df['conPow'] = df['lstrCNT'] * df['rstrCNT']
df['lstrPow'] = df['count'] / df['lstrCNT']
df['rstrPow'] = df['count'] / df['rstrCNT']
df['aux4Ratio'] = df['count'] / df['conPow']
df['aux4Log'] = df['aux4Ratio'].map(lambda x: -log(x))
**df = df[df['aux4Log'] < 11][df['lstrPow'] >= 0.5][df['rstrPow'] >= 0.5]**
df=pandas.DataFrame([[k,ass4Dict[k],k[:2],k[-2:]表示ass4Dict中的k])
df.columns=['string','count','lstr','rstr']
df=df[df['count']>=10]
**df=df[df['lstr'].map(λx:x在gram2Dict中)][df['rstr'].map(λx:x在gram2Dict中)]**
df['lstrCNT']=df['lstr'].map(lambda x:float(gram2Dict[x]))
df['rstrCNT']=df['rstr'].map(lambda x:float(gram2Dict[x]))
df['conPow']=df['lstrCNT']*df['rstrCNT']
df['lstrPow']=df['count']/df['lstrCNT']
df['rstrPow']=df['count']/df['rstrCNT']
df['aux4Ratio']=df['count']/df['conPow']
df['aux4Log']=df['aux4Ratio'].map(λx:-log(x))
**df=df[df['aux4Log']<11][df['lstrPow']>=0.5][df['rstrPow']>=0.5]**

沈钦言 359

纪小蕊 158

顾持钧 949

林晋修 642

四,

0.256721019745 1.22976207733

ch_extract.py:153:UserWarning:Boolean系列键将被重新索引以匹配数据帧索引。 df=df[df['lstr'].map(λx:x在gram2Dict中)][df['rstr'].map(λx:x在gram2Dict中)] ch_extract.py:161:UserWarning:Boolean系列键将被重新索引以匹配数据帧索引。
df=df[df['aux4Log']<11][df['lstrPow']>=0.5][df['rstrPow']>=0.5]

如果我们只是将最后一行作为以下示例重新创建:

import numpy as np
import pandas as pd

df = pd.DataFrame(np.random.randint(0,50,size=(50, 4)), columns=list('ABCD'))
df[df.A < 11][df.B >= 25][df.C >= 25]
在这种情况下,请使用loc命令:

df.loc[df.sort_values(['A'], ascending=[False]).duplicated(subset='B', keep='first')]
df[df.sort_values(['A'], ascending=[False]).duplicated(subset='B', keep='first')]
df.loc[df.sort_values(['A'], ascending=[False]).duplicated(subset='B', keep='first')]