teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

4

えらー

2019/10/24 07:00

投稿

TakamasaSanda
TakamasaSanda

スコア6

title CHANGED
File without changes
body CHANGED
@@ -9,29 +9,57 @@
9
9
 
10
10
  ### 発生している問題・エラーメッセージ
11
11
 
12
- FileNotFoundError Traceback (most recent call last)
12
+ AttributeError Traceback (most recent call last)
13
- <ipython-input-45-6133898395fe> in <module>
13
+ <ipython-input-51-675d9ee83f23> in <module>
14
14
  30 plt.show()
15
15
  31
16
16
  ---> 32 DataRead()
17
17
 
18
- <ipython-input-45-6133898395fe> in DataRead()
18
+ <ipython-input-51-675d9ee83f23> in DataRead()
19
- 6
20
- 7 def DataRead():
21
- ----> 8 with cd.open("9399_2019.csv", "r", "Shift-JIS", "ignore") as csv_file:
22
- 9 df = pd.read_csv(csv_file, quotechar='"', header=1, index_col=0)
23
19
  10
20
+ 11 df_ = df.copy()
21
+ ---> 12 df_.index = mdates.date2num(df_.index)
22
+ 13 data = df_.reset_index().values
23
+ 14
24
24
 
25
- ~/anaconda3/lib/python3.7/codecs.py in open(filename, mode, encoding, errors, buffering)
25
+ ~/anaconda3/lib/python3.7/site-packages/matplotlib/dates.py in date2num(d)
26
- 896 # Force opening of the file in binary mode
27
- 897 mode = mode + 'b'
28
- --> 898 file = builtins.open(filename, mode, buffering)
29
- 899 if encoding is None:
26
+ 424 if not d.size:
30
- 900 return file
27
+ 425 return d
28
+ --> 426 return _to_ordinalf_np_vectorized(d)
29
+ 427
30
+ 428
31
31
 
32
+ ~/anaconda3/lib/python3.7/site-packages/numpy/lib/function_base.py in __call__(self, *args, **kwargs)
33
+ 2089 vargs.extend([kwargs[_n] for _n in names])
34
+ 2090
32
- FileNotFoundError: [Errno 2] No such file or directory: '9399_2019.csv'
35
+ -> 2091 return self._vectorize_call(func=func, args=vargs)
36
+ 2092
37
+ 2093 def _get_ufunc_and_otypes(self, func, args):
33
38
 
39
+ ~/anaconda3/lib/python3.7/site-packages/numpy/lib/function_base.py in _vectorize_call(self, func, args)
40
+ 2159 res = func()
41
+ 2160 else:
42
+ -> 2161 ufunc, otypes = self._get_ufunc_and_otypes(func=func, args=args)
43
+ 2162
44
+ 2163 # Convert args to object arrays first
34
45
 
46
+ ~/anaconda3/lib/python3.7/site-packages/numpy/lib/function_base.py in _get_ufunc_and_otypes(self, func, args)
47
+ 2119
48
+ 2120 inputs = [arg.flat[0] for arg in args]
49
+ -> 2121 outputs = func(*inputs)
50
+ 2122
51
+ 2123 # Performance note: profiling indicates that -- for simple
52
+
53
+ ~/anaconda3/lib/python3.7/site-packages/matplotlib/dates.py in _to_ordinalf(dt)
54
+ 224 tzi = UTC
55
+ 225
56
+ --> 226 base = float(dt.toordinal())
57
+ 227
58
+ 228 # If it's sufficiently datetime-like, it will have a `date()` method
59
+
60
+ AttributeError: 'str' object has no attribute 'toordinal'
61
+
62
+
35
63
  ### 該当のソースコード
36
64
 
37
65
  ```python
@@ -42,7 +70,7 @@
42
70
  import codecs as cd
43
71
 
44
72
  def DataRead():
45
- with cd.open("9399_2019.csv", "r", "Shift-JIS", "ignore") as csv_file:
73
+ with cd.open("/Users/super/9399_2019.csv", "r", "Shift-JIS", "ignore") as csv_file:
46
74
  df = pd.read_csv(csv_file, quotechar='"', header=1, index_col=0)
47
75
 
48
76
  df_ = df.copy()
@@ -71,11 +99,9 @@
71
99
  ```
72
100
 
73
101
  ### 試したこと
74
- ファイルのパスが間違えていると解釈したのですが、このipynbと同じファイルに入っているので、またしてもつまづいております、、、
75
- 現在進行形で調べながらっております解決してださ方がらっゃれば教えいただけますと幸いです、、
102
+ 大文字小文字スペルミス間違だそうなのでそこを中心に確認しております
76
103
 
77
104
 
78
-
79
105
  ### 補足情報(FW/ツールのバージョンなど)
80
106
  [https://qiita.com/Nabetalion/items/73b9bd3adec62584ee3a]
81
107
  上記サイトを見本として作業しています

3

呼び出しの追加

2019/10/24 07:00

投稿

TakamasaSanda
TakamasaSanda

スコア6

title CHANGED
File without changes
body CHANGED
@@ -72,6 +72,7 @@
72
72
 
73
73
  ### 試したこと
74
74
  ファイルのパスが間違えていると解釈したのですが、このipynbと同じファイルに入っているので、またしてもつまづいております、、、
75
+ 現在進行形で調べながらやっておりますが解決してくださる方がいらっしゃれば教えていただけますと幸いです、、
75
76
 
76
77
 
77
78
 

2

誤字

2019/10/23 11:35

投稿

TakamasaSanda
TakamasaSanda

スコア6

title CHANGED
File without changes
body CHANGED
@@ -67,7 +67,7 @@
67
67
  plt.show()
68
68
 
69
69
  DataRead()
70
- ソースコード
70
+
71
71
  ```
72
72
 
73
73
  ### 試したこと

1

呼び出しの追加

2019/10/23 11:34

投稿

TakamasaSanda
TakamasaSanda

スコア6

title CHANGED
File without changes
body CHANGED
@@ -9,13 +9,40 @@
9
9
 
10
10
  ### 発生している問題・エラーメッセージ
11
11
 
12
+ FileNotFoundError Traceback (most recent call last)
13
+ <ipython-input-45-6133898395fe> in <module>
14
+ 30 plt.show()
15
+ 31
12
- outが表示されなくて、どう間違えているのか教えて欲しいです
16
+ ---> 32 DataRead()
13
17
 
18
+ <ipython-input-45-6133898395fe> in DataRead()
19
+ 6
20
+ 7 def DataRead():
21
+ ----> 8 with cd.open("9399_2019.csv", "r", "Shift-JIS", "ignore") as csv_file:
22
+ 9 df = pd.read_csv(csv_file, quotechar='"', header=1, index_col=0)
23
+ 10
24
+
25
+ ~/anaconda3/lib/python3.7/codecs.py in open(filename, mode, encoding, errors, buffering)
26
+ 896 # Force opening of the file in binary mode
27
+ 897 mode = mode + 'b'
28
+ --> 898 file = builtins.open(filename, mode, buffering)
29
+ 899 if encoding is None:
30
+ 900 return file
31
+
32
+ FileNotFoundError: [Errno 2] No such file or directory: '9399_2019.csv'
33
+
34
+
14
35
  ### 該当のソースコード
15
36
 
16
37
  ```python
38
+ import pandas as pd
39
+ import matplotlib.pyplot as plt
40
+ import matplotlib.dates as mdates
41
+ import mpl_finance as mpf
42
+ import codecs as cd
43
+
17
44
  def DataRead():
18
- with cd.open("9836_2019.csv", "r", "Shift-JIS", "ignore") as csv_file:
45
+ with cd.open("9399_2019.csv", "r", "Shift-JIS", "ignore") as csv_file:
19
46
  df = pd.read_csv(csv_file, quotechar='"', header=1, index_col=0)
20
47
 
21
48
  df_ = df.copy()
@@ -38,18 +65,16 @@
38
65
  ax.xaxis.set_major_formatter(mdates.AutoDateFormatter(locator))
39
66
  plt.legend()
40
67
  plt.show()
68
+
69
+ DataRead()
41
70
  ソースコード
42
71
  ```
43
72
 
44
73
  ### 試したこと
74
+ ファイルのパスが間違えていると解釈したのですが、このipynbと同じファイルに入っているので、またしてもつまづいております、、、
45
75
 
46
- エラーははい丁寧のでいけてると思うのですが、、
47
- jupyter notebookのkernel再接続などをしても結果は変わらずです。
48
- ![イメージ説明](0d7db5e852b7268f78490f30a8eeec39.png)
49
76
 
50
- ここに問題に対して試したことを記載してください。
51
77
 
52
78
  ### 補足情報(FW/ツールのバージョンなど)
53
- https://qiita.com/Nabetalion/items/73b9bd3adec62584ee3a
79
+ [https://qiita.com/Nabetalion/items/73b9bd3adec62584ee3a]
54
-
55
80
  上記サイトを見本として作業しています