前提・実現したいこと
ここに質問の内容を詳しく書いてください。
(例)PHP(CakePHP)で●●なシステムを作っています。
■■な機能を実装中に以下のエラーメッセージが発生しました。
株価の終値をcsvファイルから取り出してグラフにしたいと考えていますが、csvファイルからデータを取り出すときにエラーが発生しました。
発生している問題・エラーメッセージ
0 28,631.45
1 28,756.86
2 28,523.26
3 28,633.46
4 28,242.21
...
2490 10,228.92
2491 10,344.54
2492 10,292.63
2493 10,355.99
2494 10,279.19
TypeError: no numeric data to plot
python
1ソースコード 2import matplotlib.pyplot as plt 3import numpy as np 4import csv 5import pandas as pd 6 7df = pd.read_csv("stock.csv") 8 9x = df['finish'] 10x = x.replace('',',') 11 12print(x) 13plt.figure() 14x.plot() 15plt.savefig('stock.png') 16plt.show() 17plt.close('all') 18 19以下csvファイル 20"日付け","finish","始値","高値","安値","出来高","前日比%" 21"2021年01月22日","28,631.45","28,580.20","28,698.18","28,527.16","669.45M","-0.44%" 22"2021年01月21日","28,756.86","28,710.41","28,846.15","28,677.61","676.62M","0.82%" 23"2021年01月20日","28,523.26","28,798.74","28,801.19","28,402.11","697.92M","-0.38%" 24"2021年01月19日","28,633.46","28,405.49","28,720.91","28,373.34","581.76M","1.39%" 25"2021年01月18日","28,242.21","28,238.68","28,349.97","28,111.54","519.15M","-0.97%" 26"2021年01月15日","28,519.18","28,777.47","28,820.50","28,477.03","741.16M","-0.62%" 27"2021年01月14日","28,698.26","28,442.73","28,979.53","28,411.58","819.13M","0.85%" 28"2021年01月13日","28,456.59","28,140.10","28,503.43","28,133.59","708.57M","1.04%" 29"2021年01月12日","28,164.34","28,004.37","28,287.37","27,899.45","788.40M","0.09%" 30"2021年01月08日","28,139.03","27,720.14","28,139.03","27,667.75","848.72M","2.36%" 31"2021年01月07日","27,490.13","27,340.46","27,624.73","27,340.46","988.56M","1.60%" 32"2021年01月06日","27,055.94","27,102.85","27,196.40","27,002.18","726.61M","-0.38%" 33"2021年01月05日","27,158.63","27,151.38","27,279.78","27,073.46","550.01M","-0.37%" 34"2021年01月04日","27,258.38","27,575.57","27,602.11","27,042.32","515.06M","-0.68%" 35"2020年12月30日","27,444.17","27,559.10","27,572.57","27,338.56","505.87M","-0.45%" 36"2020年12月29日","27,568.15","26,936.38","27,602.52","26,921.14","594.33M","2.66%" 37"2020年12月28日","26,854.03","26,691.29","26,854.03","26,664.60","506.67M","0.74%" 38"2020年12月25日","26,656.61","26,708.10","26,716.61","26,638.28","333.99M","-0.04%" 39"2020年12月24日","26,668.35","26,635.11","26,764.53","26,605.26","479.33M","0.54%" 40"2020年12月23日","26,524.79","26,580.43","26,585.21","26,414.74","560.12M","0.33%"
試したこと
csvファイルの"finish"の列において"26524.79"ではなく"26,524.79"と表示されていることが原因であると思います。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
回答1件
あなたの回答
tips
プレビュー