Skip to main content

Posts

Showing posts from February, 2023

Are Your Intellisense Working In Jupyter Notebook?

Can you imagine a life of a programmer using an editor having no intellisense support? In today’s era where most of us are working in many programming languages at the same time, it is very difficult to remember the syntax of all the programming languages? The one thing which is most important is the underlying concept of any programming language and if you are good in those fundamentals, there are various ways to get help in writing code. It could be by using a search engine, by going through some book, by lending fellow coder’s hand, by using editor’s or IDEs capabilities, etc. My personal favorite way is by taking the help of IDE. I prefer the IDE which provides very good support for syntax and coding guidelines. In today’s article, I’m focusing on Jupyter notebook inside VS Code, which is a very common IDE these days when you are coding in Python . By default, syntax support or say intellisense support is not enabled in Jupyter Notebook in VS Code and hence we need to enable it us

How To Simplify IF In Python

Using conditionals or say IF-ELSE statement is quite common when developing any application and based on the programming language, the syntax to handle such conditionals varies but the underline concept remains the same. In this article, I’ll show you how to write an IF statement in Python to check if a given item is present in the collection or not. Have a look at the traditional way to achieve the same: fruits = [‘apple’,’orange’,’banana’,’mango’] fruit = ‘mango’ if (fruit==’apple’ or fruit==’orange’ or fruit==’banana’ or fruit==’mango’): print (‘Found the fruit’) In the above snippet, we have a collection holding multiple fruits and a variable holding one fruit. The idea here is to check whether the given fruit exists in the collection or not.  There is no problem with the above code but we do have a way to optimize it and by optimizing the code, we can achieve the below benefits: less number of lines of code less error prone no need to change code, if more items are added

Generate Pivot Table Using Python

Python is nowadays a very common language to use, especially when you want to automate something. Hence, we will go with Python to automate our today’s flow wherein we will generate a pivot table using Python and then we will save it back to Microsoft Excel. Input Data I’m considering CSV file as an input, which holds multiple columns as shown in the below sample: Scenario Let’s consider a scenario, wherein we want to generate a pivot table which depicts the interest of students based on the residence. For example, say you want to know how many students are falling under Uncertain category from Rural, then pivot table should be able to provide us with this data. Generating Pivot Table The very first thing we need to do is to grab the CSV data and bring it into the memory, so that we can perform operations on it. Yes, you guessed it right. We can go for a pandas data frame. Once data is available in a data frame, we can filter out the required columns and start our pivoting process.  He