質問編集履歴

2

参考にしたリンク先の追加

2020/03/14 11:32

投稿

Sunset_Yuhi
Sunset_Yuhi

スコア15

test CHANGED
File without changes
test CHANGED
@@ -36,6 +36,8 @@
36
36
 
37
37
  ```
38
38
 
39
+ SettingWithCopyWarning:
40
+
39
41
  A value is trying to be set on a copy of a slice from a DataFrame.
40
42
 
41
43
  Try using .loc[row_indexer,col_indexer] = value instead
@@ -51,6 +53,14 @@
51
53
  ### 試したこと
52
54
 
53
55
  警告文にあるリンク先の情報などを基に、①の行をdf_PL.loc[:,"決算期"] = df_PL.loc[:,"決算期"].str[-7:]とか、df_PL["決算期"] = df_PL["決算期"].copy().str[-7:]などと書いてみましたが、警告文は消えませんでした。
56
+
57
+
58
+
59
+ <参考リンク>
60
+
61
+ [Returning a view versus a copy - pandas](https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy)
62
+
63
+ [pandas の SettingWithCopyWarning で苦労した話](https://qiita.com/HEM_SP/items/56cd62a1c000d342bd70)
54
64
 
55
65
 
56
66
 

1

プログラムを修正

2020/03/14 11:32

投稿

Sunset_Yuhi
Sunset_Yuhi

スコア15

test CHANGED
File without changes
test CHANGED
@@ -16,9 +16,11 @@
16
16
 
17
17
  url = "https://kabutan.jp/stock/finance?code=7203"
18
18
 
19
- df_list = pd.read_html(url)
19
+ df_list = pd.read_html(url) #html内にあるテーブルをデータフレームとして取得
20
20
 
21
21
  df_PL = df_list[3].dropna()
22
+
23
+ #print(df_PL.dtypes)
22
24
 
23
25
 
24
26
 
@@ -72,8 +74,6 @@
72
74
 
73
75
  ]
74
76
 
75
-
76
-
77
77
  #print(df_PL2.dtypes)
78
78
 
79
79