Files
freeCodeCamp/curriculum/challenges/chinese/08-data-analysis-with-python/data-analysis-with-python-course/reading-data-csv-and-txt.md
2022-06-27 19:25:35 +05:30

60 lines
1.2 KiB
Markdown

---
id: 5e9a093a74c4063ca6f7c162
title: 从 CSV 和 TXT 中读取数据
challengeType: 11
videoId: ViGEv0zOzUk
bilibiliIds:
aid: 505575354
bvid: BV1tg411c7GH
cid: 409020451
dashedName: reading-data-csv-and-txt
---
# --description--
*在视频中我们使用的编辑器工具是在 notebook.ai 这个平台,你也可以选择用其他的平台,比如说 Google Colab 也是一个不错的选择。*
以下有更多的资料:
- <a href="https://github.com/krishnatray/RDP-Reading-Data-with-Python-and-Pandas" target="_blank" rel="noopener noreferrer nofollow">在 GitHub 平台的 Notebooks</a>
- <a href="https://colab.research.google.com/github/googlecolab/colabtools/blob/master/notebooks/colab-github-demo.ipynb" target="_blank" rel="noopener noreferrer nofollow">如何使用 Google Colab 来打开 GitHub 上的 Notebooks</a>
# --question--
## --text--
你如何使用 Pandas 模块导入 CSV 文件 `data.csv` 并且存储到 DataFrame 中?
## --answers--
```python
import pandas as pd
df = pd.csv("data.csv")
```
---
```python
import pandas as pd
df = pd.read_csv("data.csv")
```
---
```python
import pandas as pd
pd.read_csv("data.csv")
```
---
```python
import pandas as pd
df = pd.csv_reader("data.csv")
```
## --video-solution--
2