Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: query with invalid dtypes should fallback to python engine #10486

Closed
DSLituiev opened this issue Jul 1, 2015 · 1 comment
Closed

BUG: query with invalid dtypes should fallback to python engine #10486

DSLituiev opened this issue Jul 1, 2015 · 1 comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions
Milestone

Comments

@DSLituiev
Copy link

The following call of df.query() produces an error:

...
File "/Applications/anaconda/lib/python3.4/site-packages/numexpr/necompiler.py", line 629, in getType
raise ValueError("unkown type %s" % a.dtype.name)

ValueError: unkown type str128

in pandas 0.15.2

# -*- coding: utf-8 -*-
import re
import pandas as pd

def get_gene_site(tp):
    site = re.sub('T.$', '',tp)
    gene = site.split('%%')[0]
    t = int(re.search(r'T(\d+)$',tp).group(1))
    return gene, site, t

sub_sample_list = ['Actb%%qeqwT0',
 'Actb%%qeqwT1',
 'Actb%%qeqwT2',
 'Actb%%qeqwT3',
 'Actb%%tralalaT0',
 'Actb%%tralalaT1',
 'Actb%%tralalaT2',
 'Actb%%tralalaT3',
 'Dummy%%rrrrT0',
 'Dummy%%rrrrT1',
 'Dummy%%rrrrT2',
 'Dummy%%rrrrT3',
 ]

dict_samples = {'sample':[], 'gene':[], 'site':[], 'timepoint':[]}
for tp in sub_sample_list:
    gene, site, t = get_gene_site(tp)
    dict_samples['sample'].append(tp)
    dict_samples['gene'].append(str(gene))
    dict_samples[ 'site'].append(site)
    dict_samples['timepoint'].append(t) 

df = pd.DataFrame(dict_samples , 
                columns = ['sample', 'gene', 'site', 'timepoint'])

df.query('gene = "Actb"')
@jreback
Copy link
Contributor

jreback commented Jul 2, 2015

well, numexpr does not support this, nor are string ops actually passed. You should simply use regular indexing

df[df.gene == "Actb"]

I suppose this is a bug in that this should fall back to the python engine.

@jreback jreback added Bug Dtype Conversions Unexpected or buggy dtype conversions labels Jul 2, 2015
@jreback jreback added this to the Next Major Release milestone Jul 2, 2015
@jreback jreback changed the title query: query with invalid dtypes should fallback to python engine Jul 2, 2015
@jreback jreback changed the title query with invalid dtypes should fallback to python engine BUG: query with invalid dtypes should fallback to python engine Jul 2, 2015
tsstchoi added a commit to tsstchoi/pandas that referenced this issue Feb 26, 2016
…ace operator

The relevant issues added are :
BUG: query with invalid dtypes should fallback to python engine pandas-dev#10486
BUG: query modifies the frame when you compare with `=` pandas-dev#8664
@jreback jreback modified the milestones: 0.18.2, Next Major Release May 7, 2016
@jreback jreback closed this as completed in 881a690 May 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants