Predictive Hacks

How to Comment Multiple Lines in Jupyter Notebook

In order to comment on multiple lines at once in Jupyter Notebook, you have to select the required lines and then press the Ctrl + / .

For example:

df = pd.DataFrame()

for file in os.listdir("SampleData"):
    if file.endswith(".csv"):
        tmp = pd.read_csv(os.path.join("SampleData", file))
        df = pd.concat([df,tmp], ignore_index = True)

df.drop_duplicates(inplace= True)

Then we select all the rows and press the Ctrl and / and voilà!

# df = pd.DataFrame()

# for file in os.listdir("SampleData"):
#     if file.endswith(".csv"):
#         tmp = pd.read_csv(os.path.join("SampleData", file))
#         df = pd.concat([df,tmp], ignore_index = True)

# df.drop_duplicates(inplace= True)

Similarly, by pressing again the Ctrl and / we uncomment the code!

Share This Post

Share on facebook
Share on linkedin
Share on twitter
Share on email

Subscribe To Our Newsletter

Get updates and learn from the best

More To Explore

Python

Image Captioning with HuggingFace

Image captioning with AI is a fascinating application of artificial intelligence (AI) that involves generating textual descriptions for images automatically.

Python

Intro to Chatbots with HuggingFace

In this tutorial, we will show you how to use the Transformers library from HuggingFace to build chatbot pipelines. Let’s