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

質問編集履歴

1

エラー文の追加、質問項目の絞りこみ

2020/10/10 05:02

投稿

Shiro.Shiro
Shiro.Shiro

スコア9

title CHANGED
File without changes
body CHANGED
@@ -1,9 +1,8 @@
1
1
  以前、https://teratail.com/questions/294887 で、pandasのDataFrameに含まれる各要素を、","を区切り文字として、そこで改行を行うコードを以下の通り、教えて頂きました。
2
- その際には実行できたのですが、現在、'Series' object has no attribute 'explode'と出力されてしまうのみです。
2
+ その際には実行できたのですが、現在、以下のError文の通り、'Series' object has no attribute 'explode'と出力されてしまうのみです。
3
- ①その原因と解決方法
4
- ②explode()を用いない方法としてはどのようなものがあるか
5
- 以上2点についてお教えいただきたいです。
6
3
 
4
+ その原因と解決方法についてお教えいただきたいです。
5
+
7
6
  ご回答のほどどうかよろしくお願い致します。
8
7
 
9
8
  バージョンはjupyter lab(0.35.3)、Python(3.7.1)になります。
@@ -27,4 +26,23 @@
27
26
  # 1 def
28
27
  # 2 aaaaa
29
28
  # 3 bbbb
29
+ ```
30
+ ```Error
31
+ ---------------------------------------------------------------------------
32
+ AttributeError Traceback (most recent call last)
33
+ <ipython-input-1-c1b24f3157bf> in <module>
34
+ 6 df2 = df.copy()
35
+ 7 df2['A'] = [i.split(',') for i in df['A']]
36
+ ----> 8 df2 = pd.DataFrame(df2['A'].explode())
37
+ 9 df = df.reset_index(drop=True)
38
+ 10 print(df2)
39
+
40
+ ~\Anaconda3\lib\site-packages\pandas\core\generic.py in __getattr__(self, name)
41
+ 4374 if self._info_axis._can_hold_identifiers_and_holds_name(name):
42
+ 4375 return self[name]
43
+ -> 4376 return object.__getattribute__(self, name)
44
+ 4377
45
+ 4378 def __setattr__(self, name, value):
46
+
47
+ AttributeError: 'Series' object has no attribute 'explode'
30
48
  ```