Pandas with Python 2.7 Part 4 - CSV column manipulation

preview_player
Показать описание
In part 4 of the Pandas with Python 2.7 series, we cover the notion of column manipulation with CSV files. Pandas loads our data as objects, which then makes manipulating them extremely simple, while keeping the processing speed very robust. So here, we see how we can move columns around, remove them, add them, and even perform some basic operations soon.

Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6
Рекомендации по теме
Комментарии
Автор

and when i change the column name to any column name in my file it runs correctly

olaalsonosy
Автор

How can I Replace Strings based on column number in CSV? I mean if the value is 0 in column 2 i need to replace it with null?

yoco
Автор

How do I concatenate two columns? Thanks.

harikrishhna
Автор

having this error while trying to do column. manipulation
Traceback (most recent call last):
File "/Applications/anaconda3/lib/python3.6/site-packages/pandas/core/ops.py", line 658, in na_op
raise_on_error=True, **eval_kwargs)
File "/Applications/anaconda3/lib/python3.6/site-packages/pandas/core/computation/expressions.py", line 211, in evaluate
**eval_kwargs)
File "/Applications/anaconda3/lib/python3.6/site-packages/pandas/core/computation/expressions.py", line 122, in _evaluate_numexpr
result = _evaluate_standard(op, op_str, a, b, raise_on_error)
File "/Applications/anaconda3/lib/python3.6/site-packages/pandas/core/computation/expressions.py", line 64, in _evaluate_standard
return op(a, b)
TypeError: unsupported operand type(s) for -: 'str' and 'float'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Applications/anaconda3/lib/python3.6/site-packages/pandas/core/ops.py", line 682, in safe_na_op
return na_op(lvalues, rvalues)
File "/Applications/anaconda3/lib/python3.6/site-packages/pandas/core/ops.py", line 664, in na_op
result[mask] = op(x[mask], _values_from_object(y[mask]))
TypeError: unsupported operand type(s) for -: 'str' and 'float'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "sim_1.py", line 14, in <module>
bed_elev['t0-t1'] = bed_elev['t0']- bed_elev['t1']
File "/Applications/anaconda3/lib/python3.6/site-packages/pandas/core/ops.py", line 721, in wrapper
result = wrap_results(safe_na_op(lvalues, rvalues))
File "/Applications/anaconda3/lib/python3.6/site-packages/pandas/core/ops.py", line 692, in safe_na_op
lambda x: op(x, rvalues))
File "pandas/_libs/algos_common_helper.pxi", line 1212, in
File "/Applications/anaconda3/lib/python3.6/site-packages/pandas/core/ops.py", line 692, in <lambda>
lambda x: op(x, rvalues))
TypeError: ufunc 'subtract' did not contain a loop with signature matching types dtype('<U32') dtype('<U32') dtype('<U32')

anmolhaque
visit shbcf.ru