Use a list with the fmt parameter to specify the formatting for each column:

fmt=['%d', '%1.1f', '%1.1f', '%1.1f']

Complete example:

import numpy as np
prob_rf = [[1, 0.4, 0.4, 0.4],
           [2, 0.5, 0.5, 0.5],
           [3, 0.6, 0.6, 0.6]]
np.savetxt("foo.csv", prob_rf, delimiter=",", fmt=['%d', '%1.1f', '%1.1f', '%1.1f'])

The resulting file:

1,0.4,0.4,0.4
2,0.5,0.5,0.5
3,0.6,0.6,0.6
Answer from Carsten on Stack Overflow
🌐
W3Schools
w3schools.com › python › numpy › numpy_array_indexing.asp
NumPy Array Indexing
You can access an array element by referring to its index number. The indexes in NumPy arrays start with 0, meaning that the first element has index 0, and the second has index 1 etc. ... Get the second element from the following array. import numpy as np arr = np.array([1, 2, 3, 4]) print(arr[1]) Try it Yourself » · Get third and fourth elements from the following array and add them.
🌐
NumPy
numpy.org › doc › stable › user › basics.indexing.html
Indexing on ndarrays — NumPy v2.5 Manual
Single element indexing works exactly like that for other standard Python sequences. It is 0-based, and accepts negative indices for indexing from the end of the array. ... It is not necessary to separate each dimension’s index into its own set of square brackets.
Discussions

Trying to add 1 to the element at a certain index of a numpy array
You can add to any subscript of a NumPy array using +=. To a single index: a = np.zeros(7) a[1] += 1 To a range of indices: a[4:7] += 1 To a list of indices: a[[1, 6]] += 1 Or to a boolean mask: a[[False, False, False, False, False, False, True]] += 1 Depending on how you decide the positions to add to. If you select multiple positions, you can also add a different amount to each. The right-hand side must simply be broadcastable to the shape of the left-hand side: a = np.zeros(7) a += [0, 2, 0, 0, 1, 1, 3] More on reddit.com
🌐 r/learnpython
5
0
April 10, 2023
arrays - How to add an element at the index using numpy in python - Stack Overflow
I am new to python, Here I have an numpy array. Now, In this , I am trying to add an element in the index in the array . for x in index: output_result[x:x] = [300] But it is not getting added, More on stackoverflow.com
🌐 stackoverflow.com
arrays - Adding elements to a specified index in python Numpy - Stack Overflow
How can I place a value inside an array witha specified index. Like how can I place the number 3 inside between the 4th and the 5th element in array. number = 3 index= 5 array= np.array([ 31, 28, ... More on stackoverflow.com
🌐 stackoverflow.com
python - Index of element in NumPy array - Stack Overflow
The second method returns an array ... an empty array if var is not found. In short, they are not equivalent, and have separate use cases. 2025-04-03T15:23:40.237Z+00:00 ... Save this answer. ... Show activity on this post. This problem can be solved efficiently using the numpy_indexed library (disclaimer: I am its author); which was created to address problems of ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
GeeksforGeeks
geeksforgeeks.org › python › numpy-indexing
Numpy Array Indexing - GeeksforGeeks
December 17, 2025 - Here it adds a new axis helps in converting the 1D array into a 2D column vector with shape (3,1). We can modify array elements directly by using indexing or slicing. This makes it easy to update specific elements or ranges of elements in an array. ... The slice arr[1:3] selects elements at indices 1 and 2 and replaces them with 99. By mastering these techniques, we'll be able to manipulate and analyze data more efficiently with NumPy...
🌐
Stack Overflow
stackoverflow.com › questions › 59244333 › how-to-add-an-element-at-the-index-using-numpy-in-python
arrays - How to add an element at the index using numpy in python - Stack Overflow
In [108]: np.insert(np.arange(4),1,300) Out[108]: array([ 0, 300, 1, 2, 3]) In [109]: np.insert(np.arange(4),[1,2],[300,400]) Out[109]: array([ 0, 300, 1, 400, 2, 3])
Find elsewhere
🌐
NumPy
numpy.org › devdocs › user › basics.indexing.html
Indexing on ndarrays — NumPy v2.6.dev0 Manual
Single element indexing works exactly like that for other standard Python sequences. It is 0-based, and accepts negative indices for indexing from the end of the array. ... It is not necessary to separate each dimension’s index into its own set of square brackets.
🌐
NumPy
numpy.org › devdocs › user › how-to-index.html
How to index ndarrays — NumPy v2.6.dev0 Manual
To index specific elements in each column, make use of Advanced indexing as below: >>> arr = np.arange(3*4).reshape(3, 4) >>> arr array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]]) >>> column_indices = [[1, 3], [0, 2], [2, 2]] >>> np.arange(arr.shape[0]) array([0, 1, 2]) >>> row_indices = np.arange(arr.shape[0])[:, np.newaxis] >>> row_indices array([[0], [1], [2]])
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › python numpy array indexing
Python NumPy Array Indexing - Spark By {Examples}
March 27, 2024 - Python NumPy array indexing is used to access values in the 1-dimensional and, multi-dimensional arrays. Indexing is an operation, that uses this feature
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.indices.html
numpy.indices — NumPy v2.1 Manual
The indices can be used as an index into an array. >>> x = np.arange(20).reshape(5, 4) >>> row, col = np.indices((2, 3)) >>> x[row, col] array([[0, 1, 2], [4, 5, 6]]) Note that it would be more straightforward in the above example to extract the required elements directly with x[:2, :3].
🌐
Problem Solving with Python
problemsolvingwithpython.com › 05-NumPy-and-Arrays › 05.05-Array-Indexing
Array Indexing - Problem Solving with Python
Elements in NumPy arrays can be accessed by indexing. Indexing is an operation that pulls out a select set of values from an array. The index of a value in an array is that value's location within the array.
🌐
Programiz
programiz.com › python-programming › numpy › array-indexing
Numpy Array Indexing (With Examples)
In the above example, we have modified elements of the numbers array using array indexing. numbers[0] = 12 - modifies the first element of numbers and sets its value to 12 · numbers[2] = 14 - modifies the third element of numbers and sets its value to 14 · NumPy allows negative indexing for its array.
🌐
DataCamp
datacamp.com › doc › numpy › array-indexing
NumPy Array Indexing
NumPy array indexing allows you to access and manipulate individual elements or groups of elements within an array.
🌐
Stack Overflow
stackoverflow.com › questions › 50233649 › python-numpy-add-an-array-at-array-index
Python Numpy add an array at array index - Stack Overflow
May 8, 2018 - What you want is to help the numpy ndarray constructor with type inference. a = np.zeros(shape=(17, 1, 2), dtype=object) for i in range(10): b = [i] c = [1,2,3,4] b.append(c) a[i] = b a #array([[[0, [1, 2, 3, 4]]], # # [[1, [1, 2, 3, 4]]], # # [[2, [1, 2, 3, 4]]], # # [[3, [1, 2, 3, 4]]], # # [[4, [1, 2, 3, 4]]], # [[5, [1, 2, 3, 4]]], # [[6, [1, 2, 3, 4]]], # [[7, [1, 2, 3, 4]]], # [[8, [1, 2, 3, 4]]], # [[9, [1, 2, 3, 4]]], # [[0, 0]], # [[0, 0]], # [[0, 0]], # [[0, 0]], # [[0, 0]], # [[0, 0]], # [[0, 0]]], dtype=object)
🌐
SciPy
docs.scipy.org › doc › › numpy-1.11.0 › user › basics.indexing.html
Indexing — NumPy v1.11 Manual
May 29, 2016 - The examples work just as well when assigning to an array. See the section at the end for specific examples and explanations on how assignments work. Single element indexing for a 1-D array is what one expects. It work exactly like that for other standard Python sequences. It is 0-based, and accepts negative indices for indexing from the end of the array. ... Unlike lists and tuples, numpy arrays support multidimensional indexing for multidimensional arrays.
🌐
Vultr Docs
docs.vultr.com › python › third party › numpy › insert()
Python Numpy insert() - Insert Elements
November 15, 2024 - Apply numpy.insert() specifying the index and the new values. ... initial_array = np.array([1, 3, 4]) new_elements = [1.5, 2.5] new_array = np.insert(initial_array, [1, 2], new_elements) print(new_array)