Python in Science
Python ๐ is a great language for beginners ๐ถ (I myself started coding with it). It's especially useful for creating small tasks โ on your computer, automating file management ๐, calculations ๐งฎ, document formatting ๐...
So you won't be surprised to know that it's the preferred language among scientists ๐ฉ๐ปโ๐ฌ. A lot of artificial intelligence libraries are written in Python, but other science fields like Chemistry ๐งช use Python in their calculus programs, like the R project.
Solving a problem
Let me share a little example with you. One day, a chemist (who happens to be also my wife ๐) asked me how to transform a concrete .csv ๐ columns and rows structure into a different structure automatically.
The UV-vis spectrophotometer machine โ my wife was using at the university laboratory was outputting a format "A", and she needed a format "B" as input for the analysis software ๐จ๐ผโ๐ป(ReactLab JPlus Consulting) that was processing the scientific data.
How to decide when to automate a task
She has been doing that task manually for a week ๐ , realizing that all that time was being wasted on something that should be trivial. Time โณ that she could have been investing in doing actual scientific work.
In addition to that, she wasn't the only one who had to suffer this manual process: the machine was used by other colleagues ๐ฅผ in the present, and potentially, in the future.
This kind of situation is ideal for creating a task and make somebody more productive and probably happier ๐. To be sure about it, just sum the hours ๐ each person is wasting on a task daily, and multiply it by all the persons ๐จโ๐จโ๐งโ๐ง in that situation (and consider persons outside the organization that could benefit from it too! ๐). If the resulting number is bigger than the hours of effort ๐ฆ you will need to invest, it's generally a good idea to develop that task โ .
So I asked my wife ๐๐ฝโโ๏ธ an example for the input.csv
and the output.csv
and started working!
Some details
Python includes by default:
1- A csv module ๐งฉ that gave me the feature I needed to write the output.csv
.
2- A glob module ๐งฉ that allowed me to read the input.csv
So, I just needed to develop the logic ๐ฆพ for rearranging and restructuring the columns and row!
Finally, I just wrote a small batch file that could be clicked ๐ฑ by the user so they didn't need to use their OS terminal.
Closing time
I named the task "Bondy" as a reference to the concept of covalent bonds โ in chemistry.
I tried to keep the README very simple so people with no programming experience could use the ask without issues ๐. The harder part of the setup was installing Python, luckily MacOS includes it by default and Windows users can just download and install it without needing more than user-level computer knowledge ๐...
This task helped to publish this research paper ๐, which makes me quite happy as an old hard-core Science supporter ๐
If you are a scientist ๐จ๐ฟโ๐ฌ, I think you could benefit a lot from learning a bit of Python to create your own small tasks. If you combine that skill with some spreadsheets ๐ skills, you will be able to work faster and be more independent. Free your mind from repetitive work, learn to code today!
Did you solve any similar problems with some lines of code? Did it blow your mind ๐คฏ? Let me know in the comments ๐.