Python Pandas: Tricks and Features
realpython.com
realpython.com
E.g.
df.somemethod() \
.loc[lambda df: df.x < 2]
becomes df.somemethod() \
.query("x < 2")
One issue I've noticed is that there's a frustrating bug [2] that causes many queries to raise an error before evaluating, but this can be fixed by changing the engine argument: df.query("x.str.contains('a')", engine = "python")
1: https://pandas.pydata.org/pandas-docs/stable/generated/panda...When you are knee deep in some long-running docker container with some data analysis going on in an interactive console and get hit by a weird bug, it can be so, so helpful to easily run unit tests post-installation to verify everything is setup correctly.
It can also be a good step in CI if you build minimal docker containers that should house an installation of the package at the given commit, and have e.g. Jenkins build the container with the package installed from that commit and then launch the container with a simple command like
python -c “import mymodule; mymodule.test()”
[0] https://stackoverflow.com/questions/9200727/is-there-a-test-...