Skip to main content
Removed "new"/"thanks" text (it's considered unnecessary), embedded the linked image and added description, changed tags (support is for requesting help with the site features)
Source Link
BSMP
  • 4.8k
  • 10
  • 88
  • 109

I'm new to stackoverflow, so sorry if this is basic. I'm trying to show a code block with sample output to clarify my question. I know how to add a code block (indenting with 4 space) but I can't figure out how to show the output.

import pandas as pd
df = pd.DataFrame({'item_id':[1,2,1,1,2], 
                'shop_id':['S1', 'S1', 'S1', 'S2', 'S2'], 
                'price':[10, 20, 10, 12, 18]})
df

In a Jupyter notebook, the above will print the dataframe and I have seen other posts displaying results. How can do it?

Attempts:

  1. I have gone through this post which suggests that I can copy and paste the output from Jupyter but that didn't work.
  2. I have tried to save my notebook as htmlHTML and then insert the html snippet here. I thought when I run it it would display the output but it shows the entire html code instead.
  3. Take a screenshot of my notebook and insert a link to it here. But I don't think this is the proper way to ask a question.

Please see example of what I wanted to post
Thank you! Please see example of what I wanted to post:

Several sets of inputs and outputs where the input is a code block and the output is tabular data.

I'm new to stackoverflow, so sorry if this is basic. I'm trying to show a code block with sample output to clarify my question. I know how to add a code block (indenting with 4 space) but I can't figure out how to show the output.

import pandas as pd
df = pd.DataFrame({'item_id':[1,2,1,1,2], 
                'shop_id':['S1', 'S1', 'S1', 'S2', 'S2'], 
                'price':[10, 20, 10, 12, 18]})
df

In a Jupyter notebook, the above will print the dataframe and I have seen other posts displaying results. How can do it?

Attempts:

  1. I have gone through this post which suggests that I can copy and paste the output from Jupyter but that didn't work.
  2. I have tried to save my notebook as html and then insert the html snippet here. I thought when I run it it would display the output but it shows the entire html code instead.
  3. Take a screenshot of my notebook and insert a link to it here. But I don't think this is the proper way to ask a question.

Please see example of what I wanted to post
Thank you!

I'm trying to show a code block with sample output to clarify my question. I know how to add a code block (indenting with 4 space) but I can't figure out how to show the output.

import pandas as pd
df = pd.DataFrame({'item_id':[1,2,1,1,2], 
                'shop_id':['S1', 'S1', 'S1', 'S2', 'S2'], 
                'price':[10, 20, 10, 12, 18]})
df

In a Jupyter notebook, the above will print the dataframe and I have seen other posts displaying results. How can do it?

Attempts:

  1. I have gone through this post which suggests that I can copy and paste the output from Jupyter but that didn't work.
  2. I have tried to save my notebook as HTML and then insert the html snippet here. I thought when I run it it would display the output but it shows the entire html code instead.
  3. Take a screenshot of my notebook and insert a link to it here. But I don't think this is the proper way to ask a question.

Please see example of what I wanted to post:

Several sets of inputs and outputs where the input is a code block and the output is tabular data.

Post Migrated Here from stackoverflow.com (revisions)
Source Link

How can I post a question with sample output?

I'm new to stackoverflow, so sorry if this is basic. I'm trying to show a code block with sample output to clarify my question. I know how to add a code block (indenting with 4 space) but I can't figure out how to show the output.

import pandas as pd
df = pd.DataFrame({'item_id':[1,2,1,1,2], 
                'shop_id':['S1', 'S1', 'S1', 'S2', 'S2'], 
                'price':[10, 20, 10, 12, 18]})
df

In a Jupyter notebook, the above will print the dataframe and I have seen other posts displaying results. How can do it?

Attempts:

  1. I have gone through this post which suggests that I can copy and paste the output from Jupyter but that didn't work.
  2. I have tried to save my notebook as html and then insert the html snippet here. I thought when I run it it would display the output but it shows the entire html code instead.
  3. Take a screenshot of my notebook and insert a link to it here. But I don't think this is the proper way to ask a question.

Please see example of what I wanted to post
Thank you!