function to know if I'm using a pandas method or not

Viewed 27

I want to create a function to receive this function I created (extract_and_transform). I want this function to return true if inside my function I am using to_pandas() and in case I am not using to_pandas() I want it to return false

def extract_and_transform():
    colunas = ['nome', ' idade', ' cpf', ' ativo', ' nascimento', ' estado']
    df = colunas.to_pandas()
    return True

note: ignore the function it's just an example that was passed to me, this function is just the parameter of the function I want to create

I tried to create a function to solve the problem using the dis library but it didn't work.

import dis

def list_func_calls(fn):
    funcs = []
    bytecode = dis.Bytecode(fn)
    instrs = list(reversed([instr for instr in bytecode]))
    for (ix, instr) in enumerate(instrs):
        if instr.opname == "CALL_FUNCTION":
            load_func_instr = instrs[ix + instr.arg + 1]
            funcs.append(load_func_instr.argval)

    return ["%d. %s" % (ix, funcname) for (ix, funcname) in enumerate(reversed(funcs), 1)]
0 Answers
Related