如何将您的CSV文件连接到Jupyter Notebook?

huangapple go评论81阅读模式
英文:

How to connect your CSV file to Jupyter Notebook?

问题

我有一个来自Google Analytics的CSV文件,名为'data-export',我正在尝试在Jupyter Notebook中使用Python来打开该文件,然后稍后创建图表以进行进一步分析。

import pandas as pd
getCSV = pd.read_csv('data-export', skiprows=10, skipfooter=500, engine='python')
getCSV.head()

#错误信息
FileNotFoundError                         Traceback (most recent call last)
FileNotFoundError: [Errno 2] No such file or directory: 'data-export'

我尝试使用我在网上找到的语法,但错误消息一直告诉我找不到文件或目录。有人可以解释一下如何让代码读取该文件吗?

英文:

So I have a CSV file from google analytics called 'data-export' and I'm trying to use Python in Jupyter Notebook to basically open the file and then later, create charts for furhter analysis.

import pandas as pd
getCSV = pd.read_csv('data-export',skiprows=10,skipfooter=500,engine = 'python')
getCSV.head()

#error message
FileNotFoundError                         Traceback (most recent call last)
FileNotFoundError: [Errno 2] No such file or directory: 'data-export'

I tried using syntax I found online, however the error message keeps telling me filenotfound and no such file or directory. Can someone please explain exactly how I can get the code to read the file?

答案1

得分: 0

你需要提供文件在你本地计算机上的完整路径,而不仅仅是文件名。大多数文件路径看起来像这样:C:\Users\yeetMan\Downloads\code\scratch.csv

在文件资源管理器中找到该文件,点击它,然后点击“复制路径”。这将复制完整的文件路径。

确保在末尾包括.csv

英文:

You need to give it the full path to the file on your local machine, not just the name of it. Most file paths look like this: C:\Users\yeetMan\Downloads\code\scratch.csv

Go to the file in file explorer, click on it, and click "copy path". This will copy the full file path.

Make sure to include the .csv at the end.

huangapple
  • 本文由 发表于 2023年7月7日 06:19:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76632839.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定