Python Forum
Unexpected output - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Unexpected output (/thread-41166.html)



Unexpected output - Starter - Nov-21-2023

Hi all,
I am new to this forum and i am learning python coding. I tried to upload .CSV file from my computer with the following code but i am getting
NAMEERROR: name 'upload' is not defined
Here is the code i've written in my Google Colab

from google.colab import files
uploaded = files.upload()
after that i uploaded my .csv file from computer
import pandas as pd
import io
df = pd.read_csv((io.BytesIO)(upload[file.csv]))
when i run this code i am getting NameError: name 'upload' is not defined


RE: Unexpected output - snippsat - Nov-21-2023

Use Code tags.
When you have uploaded a file in Colab,then you do this to read it in Pandas.
import pandas as pd

df = pd.read_csv('data.csv')
df



RE: Unexpected output - Starter - Nov-22-2023

(Nov-21-2023, 12:57 PM)snippsat Wrote: Use Code tags.
When you have uploaded a file in Colab,then you do this to read it in Pandas.
import pandas as pd

df = pd.read_csv('data.csv')
df

Thank you so much for the solution. will learn next time how to post code tags