11

I hope this is not a redundant question, but I was not able to find a proper answer and tutorial. I am currently learning Data Science and therefore use kaggle competition for practice and jupyter notebook to tackle them (as it is visually more appealing to me). Now I stumbled upon an example kernel (see: http://nbviewer.jupyter.org/github/agconti/kaggle-titanic/blob/master/Titanic.ipynb#Data-Handling) is using comments, links and illustrations between his codes to give more context.

Is anybody aware of how to write such comments and remarks within jupyter? If so, do you have an online resource where I could learn this?

Thanks a bunch!

calicationoflife
  • 281
  • 2
  • 8
  • 17
  • 2
    The "comments" are markdown, which you can switch between in your cells. You just set your cell to "Markdown". – Scratch'N'Purr Feb 19 '18 at 15:49
  • So indeed a redundant question lol. Thanks a bunch for helping out though, very much appreciated. – calicationoflife Feb 19 '18 at 15:52
  • 2
    Also, you might be interested in generating Markdown as output of your code: https://stackoverflow.com/questions/36288670/how-to-programmatically-generate-markdown-output-in-jupyter-notebooks – Georgy Feb 19 '18 at 16:00

5 Answers5

9

Yep - highlight a cell and click on the "Cell" dropdown menu and go to "Cell Type" and choose "Markdown". Then you can type any markdown text you'd like and it will render as such.

^^ Also there are shortcuts for changing cell types as well. Highlight a cell and press the esc key to change into "command" mode and press m. This changes it to a markdown cell. Press y to change it back to a code cell.

You can also do latex equations using dollar signs ($). There is documentation for this here

RSHAP
  • 2,337
  • 3
  • 28
  • 39
8

For markdown cells

[//]: # "Your comment in here."

allows to include a comment in jupyter notebook server version 6.0.1. See this discussion for more details on markdown comments.

dgruending
  • 973
  • 9
  • 15
  • 1
    The quotes are important (they can be substituted with parenthesis`(Comment)`). `[//]: # Your comment in here` doesn't work. – Abby Apr 29 '20 at 06:48
4

Agree with @RSHAP. I just add the flow picture in the below.
select the active Cell > Cell Type > Markdown. enter image description here

Zgpeace
  • 3,927
  • 33
  • 31
1

irrespective of the version of jupyter notebook you use, the following command should work on current cell

  1. Pres ESC
  2. then Press m
niran
  • 1,920
  • 8
  • 34
  • 60
0

As mentioned in the above remarks, use markdown cells. Once in a markdown cell, use #,##,###,#### for headings of different fonts. For bold, use **your_text_here**, and for italics use *your_text_here*. For writing equations and using latex commands, use $ symbol. Everything works just like in latex; you can even define your notations like you would normally do in Latex. For a more detailed and structured overview to format text In Jupyter, have a look at this website:

https://www.earthdatascience.org/courses/intro-to-earth-data-science/file-formats/use-text-files/format-text-with-markdown-jupyter-notebook/

  • 1
    Ok sure, will add more details. I am a little new to contributing to stack overflow. Thanks for your remark, I will add in more context and details. :) – Gaurav Saxena Aug 24 '21 at 04:01