I have the following code to create a new dataset from an existing one, and I can’t figure out why the resulting dataset has the same data for every row. The problem arises at the end, although the variable ** Newdata** changes for every iteration, the variable

*has all its data equal to those in the last*

**Datos***row.*

**Newdata**Any ideas?

```
dataset1=system.dataset.toPyDataSet(event.source.parent.dataset1)
tagpaths=[]
fechas=[]
Newdata=[]
Datos=[]
headers=[]
headers.append('ts')
for row in range(dataset1.rowCount):
tagpath=dataset1.getValueAt(row,'pv')
if tagpath not in tagpaths:
tagpaths.append(tagpath)
headers.append(tagpath)
fecha=dataset1.getValueAt(row,'ts')
if fecha not in fechas:
fechas.append(fecha)
longitud=len(headers)
for j in range(longitud):
Newdata.append(None)
for i in range(len(fechas)):
Newdata[0]=fechas[i]
for row in range(dataset1.rowCount):
tagpath=dataset1.getValueAt(row,'pv')
valor=dataset1.getValueAt(row,'value')
ts=dataset1.getValueAt(row,'ts')
if ts==fechas[i]:
for k in range(1,longitud):
if tagpath==headers[k]:
Newdata[k]=valor
Datos.append(Newdata)
print Newdata
datos_ordenados=system.dataset.toDataSet(headers,Datos)
event.source.parent.dataset2=datos_ordenados
```