dfply icon indicating copy to clipboard operation
dfply copied to clipboard

use mask for column names with blank

Open steer629 opened this issue 6 years ago • 1 comments

for some reasons, I have a very complicate excel be read into pandas, some column names are with blank, i.e "Commercial Project-ID", target_data_frame= orginal_data_frame >> mask(X.['Commercial Project-ID']==0) or target_data_frame= orginal_data_frame >> mask(X.'Commercial Project-ID'==0) or target_data_frame= orginal_data_frame >> mask(X.Commercial Project-ID==0)

either way, not work of course I can remove the blank before the filter, but I am wondering, if there are better way to do

steer629 avatar Apr 11 '18 13:04 steer629

In addition, if you happen to have a column called isin which is a pandas function, the mask call doesn't work. It might not be exactly the same issue but could possibly be solved using a similar method as above.

Here is a minimal example which yields an error:AttributeError: 'NotImplementedType' object has no attribute 'dtype'

    pp = pd.DataFrame( {'isin': ['a','b']})
    pp >> mask(X.isin == 'b')

svenski avatar Apr 23 '18 15:04 svenski