Visual Python is a free code generator for Python that you can use to quickly insert code snippets while your code. It comes as a Jupyter Notebook extension and help you insert code Jupyter cell via single click. It offers you a visual program code generator that takes some input from you and will generate the equivalent code.
Here using the different blocks what you want to do and it will help you generate the corresponding required code. For now, you can use it to generate code for opening and reading files, importing modules, generating charts and graphs using Matplotlib and some data frames manipulation via Pandas.
In addition to code generation, it serves as a snippet manager as well. You can create some code snippets and save in it. Later when you need them then you can insert them in the Jupyter cells in a single click. Before generating any code, you can preview it and the code that it inserts in the Jupyter cells will execute automatically.
Free Python Code Generator to Write Python Programs Visually
For now many code generation components are a work in progress and in the later updates, you will be able to generate code for time series, data reshaping, and data merging.
As I mentioned earlier that this is am extension to Jupyter Notebook, so you must have Jupyter installed already. It is also recommended that you use Anaconda. But if you are on a native Python installation with Pip support, then you are good to go as well.
Run the following command to install Visual Python.
pip install visualpython
Now, you just activate and integrate it by running the following commands one after another. They will install the necessary extensions for Jupyter and then you can use it.
pip install jupyter_contrib_nbextensions
Now, open Jupyter Notebook in any folder as usual. When you open an IPYNB notebook, then you will see an orange icon to invoke Visual Python. You can see the main interface in the screenshot below.
Now, you can start generating the code. There are various blocks in Visual Python on the left side that you can see. Use the most basic one that insert import statements. In just one click, you can add all the imports that you will need. By default, it only adds the ones which are generally needed to do the data science related work.
Next, you can move to the next block, say importing files. Here it takes the type of file you want to open along with the frame type. Specify this information and then preview the code, it will generate the Pandas equivalent code for opening a CSV/JSON file. You can add the code in any cell and it will execute that as well.
Similarly, you can use it to generate code for plotting charts and graphs. Just enter the information, such as data to use and labels for X and Y axes. It will generate the equivalent Matplotlib code that you can use. You can also specify the color for those graphs and it will work just fine.
In this way, you can use this simple Jupyter extension to generate Python code automatically.
If you are looking for a tool to generate Python code automatically, then you need to try Visual Python. It is simple and for now offers quite nice tools that you will save you a lot of time. I have used a simple example sin this post, but you can use it to generate complex code of plotting graphs and charts.