4 ms·
Thanks for feedback. Yes, it's mostly about typing and hinting in the IDE, but also about maintenability. For instance, if you use string as column names, they
by TheAlchemist 4y ago
Thanks for feedback. Yes, it's mostly about typing and hinting in the IDE, but also about maintenability. For instance, if you use string as column names, they will be everywhere - it will be very difficult to refactor the code (for example - change the name of the column)
pipe is interesting indeed. However, I would still like to make specify some minimum requirement a dataframe must meet (for ex, having a column 'Date', and 'City') so that the function can perform it's action.
I've played a bit with the available tools, but none seem to work well - pandera is nice but for some reason PyCharm seem unable to leverage that, so there is no automcomplete nor warnings if the type is not appropriate.
- bradwood 4y agoWhat about just liberal use of ‘assert‘ throughout the codebase. These are good to use in production code (not just in tests). And give you a means of defensively coding and forcing errors if, for example column names are missing?
- TheAlchemist 4y agoThat wouldn't solve the problems described, would it ? If a column is missing, the code would crash anyway - that's not my issue. My issue is more about understanding and maintainability of the code, as well as ease of coding. I've found this, which seems quite close to be usable: https://strictly-typed-pandas.readthedocs.io/en/latest/ https://strictly-typed-pandas.readthedocs.io/en/latest/
- bradwood 4y agoYou may find lots of ide tools, type hinting systems and so on. But these are a bit like crutches IMHO. You don't need them to make maintainable code. If your functions are small, pure, well-tested then you are good. Small functions are much more maintainable, testable,easy to reason about, etc. So rather than worrying about code completion and type hints. Just try to work in a more functional style. It will pay big dividends.
- TheAlchemist 4y agoAgree on small functions, although it still doesn't really solve my perceived problem. Would you know some good python applications using pandas in that way that I could look at to get a better idea ?