Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unexpected output
#1
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
buran write Nov-21-2023, 12:56 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply
#2
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
Reply
#3
(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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Unexpected output when trying to attach files in a mail application PythonU2Novel 0 430 May-17-2024, 02:59 AM
Last Post: PythonU2Novel
  Unexpected Output - Python Dataframes: Filtering based on Overlapping Dates Xensor 5 933 Nov-15-2023, 06:54 PM
Last Post: deanhystad
  Unexpected output while using random.randint with def terickson2367 1 636 Oct-24-2023, 05:56 AM
Last Post: buran
  Unexpected output from df.loc when indexing by label idratherbecoding 6 1,413 Apr-19-2023, 12:11 AM
Last Post: deanhystad
  unexpected output asyrafcc99 0 1,564 Oct-24-2020, 02:40 PM
Last Post: asyrafcc99
  Unexpected output: symbols for derivative not being displayed saucerdesigner 0 2,150 Jun-22-2020, 10:06 PM
Last Post: saucerdesigner
  Unexpected output palladium 4 2,908 Jan-11-2020, 03:26 PM
Last Post: palladium
  Unexpected output: if statement CabbageMan 1 1,861 Sep-04-2019, 04:12 PM
Last Post: ThomasL
  Unexpected Output using classes and inheritance langley 2 2,058 Jul-04-2019, 09:33 AM
Last Post: langley
  float multiplication - unexpected output inesk 3 3,472 Dec-11-2018, 10:59 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020