0

I have a running code on Python 2.7.0 with pandas==0.23.4. Now when I am trying to deploy this on a new server, my df looks like below but my filter is not working? What is the issue here? This is a conda distribution. Can I reinstall python or is there a change in pandas implementation.

I tried df.query() as well but with no luck

data_df

  KPIID  CATEGORY ACTUAL_DATE
0    21  Delivery  2016-05-11
1    21  Delivery  2016-10-29
2    21  Delivery  2016-12-10
3    21  Delivery  2016-12-20
4    21  Delivery  2017-01-11
5    21  Delivery  2017-01-18
6    21  Delivery  2017-01-31
7    21  Delivery  2017-02-09
8    21  Delivery  2017-02-15
9    21  Delivery  2017-02-23

when i try :

data_df[data_df.KPIID == 21]

I am getting an empty DF :(

Empty DataFrame
  Columns: [KPIID, CATEGORY, ACTUAL_DATE]
  Index: []

I ran below code on new server

import sys
sys.version_info
sys.version_info(major=3, minor=7, micro=0, releaselevel='final', serial=0)


pd.__version__
'0.23.4'
ycx
  • 3,155
  • 3
  • 14
  • 26
s_mj
  • 530
  • 11
  • 28

2 Answers2

1

I've a feeling your KPIID values are not integer format.

Try this:

data_df.KPIID=data_df.KPIID.astype(int)
data_df[data_df.KPIID == 21]
Amit Amola
  • 2,301
  • 2
  • 22
  • 37
1

Are you sure the column KPIID is an integer and not a string?

Try using dtypes to check the type of variable stored in this column

data_df.dtypes

If it is a string you should change it to

data_df[data_df.KPIID == '21']