我有这个文件:
[.data.table
现在我需要创建数据框,在那里我可以从pentiction中读取日期数据...我可以创建数据框并使用datetime解析它但在这种情况下不使用它...
有任何建议吗?
答案 0 :(得分:1)
尝试read_csv
:
#after testing replace io.StringIO(temp) to filename
df = pd.read_csv(io.StringIO(temp),
sep="\s+",
skip_blank_lines=True,
index_col=None,
skiprows=14,
header=None,
names=['Freq','a','b','c','d','e','f','g'])
print df
Freq a b c d e f g
0 2016 Jan 30 NaN NaN NaN NaN NaN
1 245 20 17 17 -1 -1 12 -1
2 410 38 34 37 -1 -1 35 -1
3 610 56 -1 56 -1 -1 50 -1
4 1415 104 73 72 -1 -1 78 -1
5 2695 106 106 98 -1 -1 101 -1
6 2800 -1 -1 -1 105 105 -1 105
7 4995 -1 149 134 -1 -1 145 -1
8 8800 287 269 261 -1 -1 275 -1
9 15400 514 573 536 -1 -1 515 -1
10 2016 Jan 31 NaN NaN NaN NaN NaN
11 245 21 18 20 -1 -1 32 -1
12 410 39 17 38 -1 -1 46 -1
13 610 58 -1 56 -1 -1 60 -1
14 1415 91 74 72 -1 -1 78 -1
15 2695 102 103 97 -1 -1 100 -1