我目前正在处理此link的数据集。但我无法从熊猫中读取这些文件?有没有人试过玩这样的文件?
我正在尝试以下方法:
import pandas as pd
df = pd.read_csv("m_4549381c276b46c6.0000")
但是我收到以下错误
Error tokenizing data. C error: Buffer overflow caught - possible malformed input file.
答案 0 :(得分:3)
这些文件是已保存的SFrame的一部分。
所以你可以这样加载它们:
import sframe
sf = sframe.SFrame('/path/to/dir/')
演示:我已从people_wiki.gl下载了所有文件并将其置于:D:/download/sframe/
In [7]: import sframe
In [7]: sf = sframe.SFrame('D:/download/sframe/')
In [8]: sf
Out[8]:
Columns:
URI str
name str
text str
Rows: 59071
Data:
+-------------------------------+---------------------+
| URI | name |
+-------------------------------+---------------------+
| <http://dbpedia.org/resour... | Digby Morrell |
| <http://dbpedia.org/resour... | Alfred J. Lewy |
| <http://dbpedia.org/resour... | Harpdog Brown |
| <http://dbpedia.org/resour... | Franz Rottensteiner |
| <http://dbpedia.org/resour... | G-Enka |
| <http://dbpedia.org/resour... | Sam Henderson |
| <http://dbpedia.org/resour... | Aaron LaCrate |
| <http://dbpedia.org/resour... | Trevor Ferguson |
| <http://dbpedia.org/resour... | Grant Nelson |
| <http://dbpedia.org/resour... | Cathy Caruth |
+-------------------------------+---------------------+
+-------------------------------+
| text |
+-------------------------------+
| digby morrell born 10 octo... |
| alfred j lewy aka sandy le... |
| harpdog brown is a singer ... |
| franz rottensteiner born i... |
| henry krvits born 30 decem... |
| sam henderson born october... |
| aaron lacrate is an americ... |
| trevor ferguson aka john f... |
| grant nelson born 27 april... |
| cathy caruth born 1955 is ... |
+-------------------------------+
[59071 rows x 3 columns]
Note: Only the head of the SFrame is printed.
You can use print_rows(num_rows=m, num_columns=n) to print more rows and columns.
现在,如果需要,您可以将其转换为Pandas DF:
In [17]: df = sf.to_dataframe()
In [18]: pd.options.display.max_colwidth = 40
In [19]: df.head()
Out[19]:
URI name text
0 <http://dbpedia.org/resource/Digby_M... Digby Morrell digby morrell born 10 october 1979 i...
1 <http://dbpedia.org/resource/Alfred_... Alfred J. Lewy alfred j lewy aka sandy lewy graduat...
2 <http://dbpedia.org/resource/Harpdog... Harpdog Brown harpdog brown is a singer and harmon...
3 <http://dbpedia.org/resource/Franz_R... Franz Rottensteiner franz rottensteiner born in waidmann...
4 <http://dbpedia.org/resource/G-Enka> G-Enka henry krvits born 30 december 1974 i...
In [20]: df.shape
Out[20]: (59071, 3)
答案 1 :(得分:2)