MCPcopy Create free account
hub / github.com/ScottfreeLLC/AlphaPy / vunapply

Function vunapply

alphapy/variables.py:546–585  ·  view source on GitHub ↗

r"""Remove a variable from multiple dataframes. Parameters ---------- group : alphapy.Group The input group. vname : str The variable to remove from the ``group``. Returns ------- None : None Other Parameters ---------------- Frame.frames :

(group, vname)

Source from the content-addressed store, hash-verified

544#
545
546def vunapply(group, vname):
547 r"""Remove a variable from multiple dataframes.
548
549 Parameters
550 ----------
551 group : alphapy.Group
552 The input group.
553 vname : str
554 The variable to remove from the ``group``.
555
556 Returns
557 -------
558 None : None
559
560 Other Parameters
561 ----------------
562 Frame.frames : dict
563 Global dictionary of dataframes
564
565 See Also
566 --------
567 vapply
568
569 """
570 # get all frame names to apply variables
571 gnames = [item.lower() for item in group.all_members()]
572 # apply the variables to each frame
573 for g in gnames:
574 fname = frame_name(g, group.space)
575 if fname in Frame.frames:
576 f = Frame.frames[fname].df
577 logger.info("Unapplying variable %s from %s", vname, g)
578 if vname not in f.columns:
579 logger.info("Variable %s not in %s frame", vname, g)
580 else:
581 estr = "Frame.frames['%s'].df = f.df.drop('%s', axis=1)" \
582 % (fname, vname)
583 exec(estr)
584 else:
585 logger.info("Frame not found: %s", fname)
586
587
588#

Callers 1

vmunapplyFunction · 0.85

Calls 1

frame_nameFunction · 0.90

Tested by

no test coverage detected