I've noticed that people produce such an amazing pandas dataframe which allows people to answer the questions. However, whenever I try to copy my table after doing df.head(), and "paste" it on here so that I am able to ask a question it leaves me with a table that needs to be restructured.

I have searched for similar questions here but have been struggling to find a step-by-step answer on how to ask questions especially when it is related to pandas and that one has to get a sense of the data at hand before being able to provide an answer.

  • $\begingroup$ You can paste it as a csv or as a json so people can load the data. And you can also take a screenshot of the dataframe so people can see it easily. $\endgroup$
    – JahKnows
    May 21, 2020 at 16:05

1 Answer 1


will give something which looks like

{'x': {0: 1, 1: 200, 2: 4, 3: 5, 4: 6}, 'y': {0: 4, 1: 5, 2: 10, 3: 24, 4: 4}}

you can then add pd.DataFrame() like so

pd.DataFrame({'x': {0: 1, 1: 200, 2: 4, 3: 5, 4: 6}, 
              'y': {0: 4, 1: 5, 2: 10, 3: 24, 4: 4}})

This will allow anybody else just to copy and paste into their editor and run your code.

Here is a really detailed discussion on what you are describing https://stackoverflow.com/a/20159305/6646710


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.