TypeError Traceback (most recent call last)
C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\ops.py in na_op(x, y)
657 result = expressions.evaluate(op, str_rep, x, y,
--> 658 raise_on_error=True, **eval_kwargs)
659 except TypeError:
C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\computation\expressions.py in evaluate(op, op_str, a, b, raise_on_error, use_numexpr, eval_kwargs)
210 return _evaluate(op, op_str, a, b, raise_on_error=raise_on_error,
--> 211 eval_kwargs)
212 return _evaluate_standard(op, op_str, a, b, raise_on_error=raise_on_error)
C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\computation\expressions.py in _evaluate_numexpr(op, op_str, a, b, raise_on_error, truediv, reversed, **eval_kwargs)
121 if result is None:
--> 122 result = _evaluate_standard(op, op_str, a, b, raise_on_error)
123
C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\computation\expressions.py in _evaluate_standard(op, op_str, a, b, raise_on_error, **eval_kwargs)
63 with np.errstate(all='ignore'):
---> 64 return op(a, b)
65
TypeError: unsupported operand type(s) for /: 'float' and 'str'
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
in ()
----> 1 pop_Seoul['외국인비율'] = pop_Seoul['외국인'] / pop_Seoul['인구수'] * 100
2 pop_Seoul['고령자비율'] = pop_Seoul['고령자'] / pop_Seoul['인구수'] * 100
3 pop_Seoul.head()
C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\ops.py in wrapper(left, right, name, na_op)
719 lvalues = lvalues.values
720
--> 721 result = wrap_results(safe_na_op(lvalues, rvalues))
722 return construct_result(
723 left,
C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\ops.py in safe_na_op(lvalues, rvalues)
680 try:
681 with np.errstate(all='ignore'):
--> 682 return na_op(lvalues, rvalues)
683 except Exception:
684 if isinstance(rvalues, ABCSeries):
C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\ops.py in na_op(x, y)
662 result = np.empty(x.size, dtype=dtype)
663 mask = notnull(x) & notnull(y)
--> 664 result[mask] = op(x[mask], _values_from_object(y[mask]))
665 elif isinstance(x, np.ndarray):
666 result = np.empty(len(x), dtype=x.dtype)
TypeError: unsupported operand type(s) for /: 'float' and 'str'
안녕하세요? 1장 CCTV 코드 실행시 type 에러가 발생 하는데 환경 문제인지 코드 문제인지 모르겠습니다.
CODE
pop_Seoul['외국인비율'] = pop_Seoul['외국인'] / pop_Seoul['인구수'] 100 pop_Seoul['고령자비율'] = pop_Seoul['고령자'] / pop_Seoul['인구수'] 100 pop_Seoul.head()
===============에러=======================
TypeError Traceback (most recent call last) C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\ops.py in na_op(x, y) 657 result = expressions.evaluate(op, str_rep, x, y, --> 658 raise_on_error=True, **eval_kwargs) 659 except TypeError:
C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\computation\expressions.py in evaluate(op, op_str, a, b, raise_on_error, use_numexpr, eval_kwargs) 210 return _evaluate(op, op_str, a, b, raise_on_error=raise_on_error, --> 211 eval_kwargs) 212 return _evaluate_standard(op, op_str, a, b, raise_on_error=raise_on_error)
C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\computation\expressions.py in _evaluate_numexpr(op, op_str, a, b, raise_on_error, truediv, reversed, **eval_kwargs) 121 if result is None: --> 122 result = _evaluate_standard(op, op_str, a, b, raise_on_error) 123
C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\computation\expressions.py in _evaluate_standard(op, op_str, a, b, raise_on_error, **eval_kwargs) 63 with np.errstate(all='ignore'): ---> 64 return op(a, b) 65
TypeError: unsupported operand type(s) for /: 'float' and 'str'
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)