We Are Going To Discuss About TypeError: Field elements must be 2- or 3-tuples, got ‘5.0’. So lets Start this Python Article.
TypeError: Field elements must be 2- or 3-tuples, got ‘5.0’
- How to solve TypeError: Field elements must be 2- or 3-tuples, got '5.0'
It would help to know what you are trying to achieve with this code.
Assuming you are trying to create a 2D array with numpy – you need to make sure your dimensions are correct (first row with 3 element and second row with 2 element cannot make a 2D array).
And you need another [] around to make 2D array. Something like this –import numpy as np a = np.array([[8.0,7.0,6.0],[5.0,4.0,3.0]]) print(a)
- TypeError: Field elements must be 2- or 3-tuples, got '5.0'
It would help to know what you are trying to achieve with this code.
Assuming you are trying to create a 2D array with numpy – you need to make sure your dimensions are correct (first row with 3 element and second row with 2 element cannot make a 2D array).
And you need another [] around to make 2D array. Something like this –import numpy as np a = np.array([[8.0,7.0,6.0],[5.0,4.0,3.0]]) print(a)
Solution 1
It would help to know what you are trying to achieve with this code.
Assuming you are trying to create a 2D array with numpy – you need to make sure your dimensions are correct (first row with 3 element and second row with 2 element cannot make a 2D array).
And you need another [] around to make 2D array. Something like this –
import numpy as np
a = np.array([[8.0,7.0,6.0],[5.0,4.0,3.0]])
print(a)
Original Author Syed Nakib Hossain Of This Content
Solution 2
There are two mistakes here,
i. another element has to be inserted into the second array / removed from the first array,
ii. both of them have to be passed as first argument i.e. enclosed in braces.
Rewriting the same:
import numpy as np
a = np.array(([8.0,7.0,6.0],[5.0,4.0,3.0]))
print(a)
Original Author Nilesh Kumar Of This Content
Conclusion
So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.