我点名的数据帧以下数据in_file
:无法子集大熊猫数据帧
Client Value_01 Value_02 Date
ABC 100 500 2016-09-01T
ABC 14 90 2016-09-02T
DEF 95 1000 2016-09-01T
DEF 200 600 2016-09-02T
GHI 75 19 2016-09-01T
GHI 300 700 2016-09-02T
JKL 50 02 2016-09-01T
JKL 400 800 2016-09-02T
我子集以下(我们称之为“子集1”)的数据帧:
df_01 = in_file.loc[(in_file.Date == '2016-09-01T') & (in_file.Client <> 'ABC') & (in_file.Client <> 'DEF')].sort_values('Value_01', ascending=False)
和我回去:
Client Value_01 Value_02 Date
GHI 75 19 2016-09-01T
JKL 50 02 2016-09-01T
于是,我试图子集以下数据帧(这是我们”会打电话 '集2'):
df_02 = in_file.loc[(in_file.Date == '2016-09-01T') & (in_file.Client == 'ABC') & (in_file.Client == 'DEF')].sort_values('Value_01', ascending=False)
随着 '集2',我回来了空数据帧。但是,我期待看到以下内容:
Client Value_01 Value_02 Date
ABC 100 500 2016-09-01T
DEF 95 1000 2016-09-01T
有谁知道为什么“集2”的代码没有返回,我希望将数据帧?
在此先感谢。
你想'(in_file.Client =='ABC')&(in_file.Client =='DEF')'?两者在同一时间是真实的吗? –
试试这个:'in_file.loc [(in_file.Date =='2016-09-01T')&(in_file.Client.isin(['ABC','DEF'])]。sort_values('Value_01',ascending = False)' – MaxU
是否有'isin'的对应物,可以让我排除某些数据? – equanimity