# Using \`numpy\_to\_vtk\` I can't seem to get arrays to stay in dataset?

**URL:** https://discourse.vtk.org/t/using-numpy-to-vtk-i-cant-seem-to-get-arrays-to-stay-in-dataset/12425
**Category:** Support
**Created:** [October 5, 2023, 2:56pm UTC](https://discourse.vtk.org/t/using-numpy-to-vtk-i-cant-seem-to-get-arrays-to-stay-in-dataset/12425 "2023-10-05T14:56:51Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![rexthor](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rexthor/32/6481_2.png) [@rexthor](https://discourse.vtk.org/u/rexthor)
#### Post date: [October 5, 2023, 6:06pm UTC](https://discourse.vtk.org/t/using-numpy-to-vtk-i-cant-seem-to-get-arrays-to-stay-in-dataset/12425/2 "2023-10-05T18:06:32Z")

</div>

It seemed that the obvious answer was to not have NumPy allocate the data memory.  
This is related to [a problem I had earlier](https://discourse.vtk.org/t/problems-using-vtkfloatarray/12416).

So, rather than:

```python
a = numpy_to_vtk(large_NumPy_array)
dataset.GetPointData().AddArray(a)
dataset.Modified()

```

I did this:

```python
a = vtk.vtkFloatArray()
a.SetNumberOfComponents(1)
for e in large_NumPy_array:
    a.InsertInextValue(e)

dataset.GetPointData().AddArray(a)
dataset.Modified()

```

---

_[View the full topic](https://discourse.vtk.org/t/using-numpy-to-vtk-i-cant-seem-to-get-arrays-to-stay-in-dataset/12425)._
