# Can I modify an entire column from a dataset with system.dataset.setValue()?

**URL:** <https://forum.inductiveautomation.com/t/can-i-modify-an-entire-column-from-a-dataset-with-system-dataset-setvalue/87043>\
**Category:** Ignition\
**Tags:** python, vision, scripting\
**Created:** [March 8, 2024, 3:39pm UTC](https://forum.inductiveautomation.com/t/can-i-modify-an-entire-column-from-a-dataset-with-system-dataset-setvalue/87043 "2024-03-08T15:39:29Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 8, 2024, 4:23pm UTC](https://forum.inductiveautomation.com/t/can-i-modify-an-entire-column-from-a-dataset-with-system-dataset-setvalue/87043/3 "2024-03-08T16:23:52Z")

</div>

```python
def mapColumn(function, dataset, column):
	if isinstance(column, basestring):
		column = dataset.getColumnIndex(column)

	columnData = map(function, dataset.getColumnAsList(column))
	columnsToKeep = range(dataset.columnCount)
	columnsToKeep.pop(column)
	dsWithoutColumn = system.dataset.filterColumns(dataset, columnsToKeep)
	
	return system.dataset.addColumn(
		dsWithoutColumn, 
		column, 
		columnData, 
		dataset.getColumnName(column), 
		dataset.getColumnType(column)
	)

```

It's relatively easy to create a 'mapColumn' function composed of our base primitives. This will be pretty efficient.  
Usage is pretty simple - just declare a function that performs the calculation you want, for each value in the column, then supply it (no parenthesis!) to the mapColumn function:

```python
# usage:
def updateColumn(value):
	return value * 2

updatedDs = mapColumn(updateColumn, ds, "b")

```

On my test dataset, this does what you'd expect:

```auto
a | b | c
1 | 2 | 3
4 | 5 | 6

a | b | c
1 | 4 | 3
4 | 10 | 6

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/can-i-modify-an-entire-column-from-a-dataset-with-system-dataset-setvalue/87043)._
