pandasライブラリを使用してデータを含むcsvファイルを作成しようとしています。両方のための8294
:私は値を取得print len(data)
とprint len(index)
を行うことでcsvファイルにpandasを使用したときの渡された値のエラー
date = chaine[:10] + " " + chaine[11:]
date = parseDate(date)
i = str(date).replace('-','')
i = str(i).replace(':','')
i = str(i).replace(' ','')
index.append(date)
data.append(row[2])
:私はこのようなデータ(numerci値)とインデックス(値の日付)を作成します。 (任意の日付の任意の値を同じテキストを意味する):Iインデックス、データ及びヘッダを渡す
reader = csv.reader(file)
firstline = next(reader)
sensorname = firstline[0]
secondline = next(reader)
colname = sensorname+secondline[2].replace("D1a","")
header = [colname for row in secondline[2]]
このコードによって、私はすべての行に対して同じテキストを含む最初の列である見出しを作成しますこのようなデータフレームに:
import pandas as pd
newDataframe = pd.DataFrame(data, index=index, columns=header)
ここで私が得るエラーは以下のとおりです。
ERROR :: Shape of passed values is (1, 8294), indices imply (2, 8294)
newDataframe = pd.DataFrame(data, index=index, columns=header)
File "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py", line 279, in __init__
copy=copy)
File "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py", line 432, in _init_ndarray
return create_block_manager_from_blocks([values], [columns, index])
File "/usr/local/lib/python2.7/dist-packages/pandas/core/internals.py", line 3993, in create_block_manager_from_blocks
construction_error(tot_items, blocks[0].shape[1:], axes, e)
File "/usr/local/lib/python2.7/dist-packages/pandas/core/internals.py", line 3970, in construction_error
passed, implied))
ValueError: Shape of passed values is (1, 8294), indices imply (2, 8294)
は、残念ながら、私のコードは非常に複雑ですが、私は最も重要な部分をproviedしようとしました。 私のファイルはこのようなものでなければなりません:私は、ヘッダー内の何かが欠け
"measure:pressure","20161203070000","34.243"
"measure:pressure","20161204070000","3.53"
"measure:pressure","20160403070000","77.1"
アム?
この質問と回答はこちら[http://stackoverflow.com/questions/19630265/valueerror-shape-of-passed-values-is-3-27-indices-imply-4-27-pandas- da)助けてもらえますか? – gincard
あなたはcsvファイルを書いたり読んでいますか? –
多分あなたはhttp://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.htmlとhttp://pandas.pydata.org/pandas-docs/stable/generated/pandasをチェックしたいと思うかもしれません。 DataFrame.to_csv.html –