mito
mito copied to clipboard
Allow Python Snippets in Cells
As doing some analysis, I wanted to count the number of items in a list, each cell containing one list. This would've been straight forward to do in Python, but not possible in Mito.
Ideally, I would like to write a single statement that gets applied to every cell. For example, I was looking to write the python code len(column_name.split(','))
. However, handling this might be constrictive to more advanced python usage.
There is a previous comment about this by @franceme in Discussions about this, however moving it here for visibility. Their specific post was:
As a user, I would like the ability to use Python snippets within formulas to create columns. Using Python for certain functions may make things easier in scenarios.
Ex: Create a column of File Extensions based on a column of Files Python: os.path.basename(dataframe['File'].str) or something similar
Copying over @naterush's previous thoughts on implentation as well:
- We should be thoughtful about how we handle imports (e.g. os here would need to be in scope). Pandas has useful built ins as well.
- We shouldn't be restrictive on what this code can return - it would be useful to be able to compute intermediate results that aren't just series...
- How to handle multi-line statements?
This could be a useful feature as you suggest but from a CyberSecurity point of view I wonder if that functionality could be subverted for other purposes.
I would hope that by allowing snippets to be run, that a Nefarious Threat Actor (Hows that for CyberSecurity terminology), couldn't run something like "import naughty_ module" and then in a second column be able to execute code utilising info loaded from the Naughty module.