0

I converted a list to a dataframe using the following code:

List1 = ['apple', '123', 'xy24']
df = pd.DataFrame(List1)
df

Output:

(Nothing)

It's not displaying the dataframe.

I tried printing the list by giving

print(List1)

Output:

['apple', '123', 'xy24']
ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • 2
    Try `print(df)` instead of just `df`. – John Gordon Apr 02 '23 at 18:14
  • Usually str() and repr() are used to print something understandable, but without knowing wich IDE you are using it is impossible to say why the output is empty. however, a `print(df)` maybe is enough. – Glauco Apr 02 '23 at 18:59
  • Simply calculating things will not cause anything to display *in a script*. That *only* happens at an interpreter prompt, and it happens because *the prompt* is displaying the computed result, not the Python code. Please see the linked duplicate for details. – Karl Knechtel Apr 02 '23 at 19:24

1 Answers1

0

try

from IPython.display import display
display(df)

output

       0
0  apple
1    123
2   xy24

Roy
  • 398
  • 2
  • 12