あるディレクトリの中にある複数の.csvファイルを読み込み、ひとつのデータフレームにしたいと考えています
そこで以下のコードを実行したのですがエラーとなります
csv_all の型を見ると
<class 'pandas.core.frame.DataFrame'>
となっているので問題ないように思うのですがなにが間違っているでしょうか?
初歩的な質問ですが宜しくお願い致します。
python
1path = r'C:\Users\Desktop\分析用\line' 2all_files = glob.glob(os.path.join(path, "*.csv")) 3 4df = pd.DataFrame 5for f in all_files: 6 csv_all = pd.read_csv(f, engine='python') 7 df = pd.concat(csv_all, ignore_index=True) 8 9df.describe()
以下エラー
python
1TypeError Traceback (most recent call last) 2<ipython-input-55-dfb850a24b45> in <module>() 3 7 csv_all = pd.read_csv(f, engine='python') 4 8 print(type(csv_all)) 5----> 9 df = pd.concat(csv_all, ignore_index=True) 6 10 7 11 df.describe() 8 9~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\reshape\concat.py in concat(objs, axis, join, join_axes, ignore_index, keys, levels, names, verify_integrity, sort, copy) 10 223 keys=keys, levels=levels, names=names, 11 224 verify_integrity=verify_integrity, 12--> 225 copy=copy, sort=sort) 13 226 return op.get_result() 14 227 15 16~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\reshape\concat.py in __init__(self, objs, axis, join, join_axes, keys, levels, names, ignore_index, verify_integrity, copy, sort) 17 239 raise TypeError('first argument must be an iterable of pandas ' 18 240 'objects, you passed an object of type ' 19--> 241 '"{name}"'.format(name=type(objs).__name__)) 20 242 21 243 if join == 'outer': 22 23TypeError: first argument must be an iterable of pandas objects, you passed an object of type "DataFrame"
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/08/10 05:22
2018/08/10 06:04
2018/08/10 06:07