All Questions
Tagged with multidimensional-array python
3,718 questions
-2
votes
1
answer
107
views
How do I insert a multi-dimensional dictionary into a SQL database in python [closed]
My database schema is as below for sqlite3
sql_create_dynamic_parse_table = """ CREATE TABLE IF NOT EXISTS dynamic_stauts_tags (
key_tag VARCHAR NOT NULL,
tag TEXT NOT NULL,
...
0
votes
1
answer
81
views
how to create uniform nested lists and convert them in to multi dimensional arrays?
i would like to create a nested list of arbitrary depth (containing numerical values specifically) with uniform arbitrary lengths at each level and then compress it to a NumPy array of minimum ...
0
votes
1
answer
63
views
Cut-and-overlap reduction of N-dimensional array
Note: I have no idea what one might call this operation, so I've gone with "cut-and-overlap". Please let me know if there is an accepted terminology for something like this!
Intro
I need to ...
0
votes
0
answers
31
views
How to convolve a 3D array with Lorentzian kernel along axis=2?
I have an array img_data of shape (x, x, n_channels) and I want to convolve / smooth along the axis=2.
Specifically, I would like the output shape to be (x,x,n_channels//3), after convolving the ...
-3
votes
1
answer
50
views
How to make percent chance that there will be a * in a 2D array decrease
My result
I need to make the number of stars decrease with each line, but I have no idea how.
import random
import numpy as np
import sys
size = int(sys.argv[1])
mat = np.full((size, size), '\x1b[35m....
0
votes
1
answer
65
views
Writing to multidimensional arrays with variable dimension
I've initialized a list of arrays of different dimensions in Python and want to write to the entries of the arrays. If I want to write to the entry list[i, m1, m1, ..., m1, m2, m2, ..., m2] where m1 ...
0
votes
2
answers
102
views
Clever way to write a nested for loop or N dimensional array as a string
I'm working on a tool to create inputs for array simulations, where various inputs are iterated over multiple series to create all combinations of inputs. Some values need to iterate coupled together, ...
1
vote
0
answers
81
views
How to interpolate a multidimensional xarray DataArray?
I am using the xarray library and I have some doubts/questions.
I have this dataset::
ds
<xarray.Dataset> Size: 2GB
Dimensions: (Latitude: 364, Longitude: 246, Lon_u: 247, Lat_v: 364,
...
0
votes
1
answer
104
views
Xarray.open_dateset uses more than double the size of the file itself
All,
I am opening NetCDF files from Copernicus data center using xarray version 2024-11-0, using open_dataset function as the following:
import xarray as xr
file1=xr.open_dataset("2021-04.nc"...
0
votes
0
answers
50
views
Extensive merging of nested list with capacity restriction
I have a nested list on which I want to perform merging under certain restrictions.
This is my nested list:
[[[0.0, 2.0], [6.0, 20.0]],
[[0.0, 5.0], [6.0, 12.0]],
[[2.0, 5.0], [20.0, 12.0]...
-3
votes
1
answer
79
views
Why can't I stack 3D arrays with np.concatenate in numpy, while 1D and 2D arrays work?
I'm working with 3D numpy arrays and having trouble stacking two of them. Here’s what I’m trying to do:
import numpy as np
grid = np.arange(16).reshape((1, 4, 4))
grid2 = grid[:, :-1, ::-1].copy()
I ...
3
votes
2
answers
90
views
Adding 2D numpy arrays with differing axes arrays: how to properly replace the deprecated interp2d with RectBivariateSpline?
I need to add two 2D numpy arrays of possibly different shapes and different corresponding axes arrays.
What I mean is this: Lets define two different sets of x- and y-axes, and calculate the z-values ...
2
votes
4
answers
149
views
Why the result is different? Numpy Slicing and indexing
Basically I want to obtain a part of the variable "cubote". I tried two methods that should work in the same way, but it didn't.
My code:
import numpy as np
# Create a 3x3x3 cube
...
2
votes
3
answers
299
views
Python: Average Values in 2D-Array
I want to generate a twodimensional array in Python and I would like to iterate through each element and take an average. An element i should be averaged using the 8 surrounding array elements (...
1
vote
1
answer
74
views
Adding a multi-dimensional column to a pandas dataframe
I have two dataframes which look something like the following:
issue_df
COL1 COL2 REF
0 Name1 Val1 [REF1, REF2]
1 Name2 Val2 None
2 Name3 Val3 [REF1, ...