
ValueError: setting an array element with a sequence. Since tuples are sequences, the error “Setting an array element with a sequence” will occur because numpy arrays require scalar values. We are attempting to assign a tuple (1, 2) to the element at index (0, 0) of the array. In this case, we have a 2×2 numpy array arr filled with zeros. ValueError: setting an array element with a sequence.Įxample 2: Assigning a tuple to a numpy array element import numpy as np Since the element being assigned is a sequence (a list), which violates the homogeneous property, a ValueError will be raised.įile “C:\Users\Dell\PycharmProjects\Python-Code-Example\main.py”, line 4, in However, numpy arrays are homogeneous, meaning they can only hold elements of a single data type. In this example, we are trying to assign a list to the first element of the numpy array arr.

The detected shape was (18,) + inhomogeneous part.Example 1: Assigning a list to a numpy array element: import numpy as np The requested array has an inhomogeneous shape after 1 dimensions. Subarr = np.array(arr, dtype=dtype, copy=copy) Subarr = _try_cast(data, dtype, copy, raise_cast_failure)įile ~.conda\envs\work\lib\site-packages\pandas\core\construction.py:784 in _try_cast I then normalize the dataset by adjusting for RSLR:ĭf_water_levles_corrected=df_water_py().sort_index(ascending=True).astype(float).dropna()ĭf_water_levels_corrected=df_water_levels_corrected-(df_water_levels_datetime("1992"))/pd.to_timedelta("365.2425D")*measured_rslrĪm=pyextremes.EVA(df_water_levels_corrected)Įverything works up until this point and here is the command that results in the error:Īm.get_extremes(method="BM", block_size="365.2425D",errors="ignore")Ĭ:\Users: NoDataBlockWarning: 1 blocks contained no dataįile ~.conda\envs\work\lib\site-packages\pyextremes\eva.py:452 in get_extremesįile ~.conda\envs\work\lib\site-packages\pyextremes\extremes\extremes.py:59 in get_extremesįile ~.conda\envs\work\lib\site-packages\pyextremes\extremes\block_maxima.py:148 in get_extremes_block_maximaįile ~.conda\envs\work\lib\site-packages\pandas\core\series.py:451 in initĭata = sanitize_array(data, index, dtype, copy)įile ~.conda\envs\work\lib\site-packages\pandas\core\construction.py:594 in sanitize_array
Setting an array element with a sequence. download#
I'm following exact tutorial case but using data from a different noaa station using the NOAA_COOPS function to download the data into a dataframe. I also get the error when I try to execute some of the plot functions and POT functions. I'm getting the same error as wiz21b when I run the get_extremes command. The detected shape was (731,) + inhomogeneous part.Ĭool thanks. > 760 subarr = np.array(arr, dtype=dtype, copy=copy)


> 570 subarr = _try_cast(data, dtype, copy, raise_cast_failure)ĥ72 subarr = maybe_convert_platform(data)įile ~/.local/lib/python3.9/site-packages/pandas/core/construction.py:760, in _try_cast(arr, dtype, copy, raise_cast_failure)ħ55 subarr = maybe_cast_to_integer_array(arr, dtype)ħ57 # 4 tests fail if we move this to a try/except/else seeħ58 # test_constructor_compound_dtypes, test_constructor_cast_failureħ59 # test_constructor_dict_cast2, test_loc_setitem_dtype > 439 data = sanitize_array(data, index, dtype, copy)Ĥ41 manager = get_option("mode.data_manager")įile ~/.local/lib/python3.9/site-packages/pandas/core/construction.py:570, in sanitize_array(data, index, dtype, copy, raise_cast_failure, allow_2d)ĥ69 if dtype is not None or len(data) = 0: > 1 model.get_extremes(method="BM", block_size="10D")įile ~/.local/lib/python3.9/site-packages/pyextremes/eva.py:452, in EVA.get_extremes(self, method, extremes_type, **kwargs)Ĥ50 message = f"for method=' blocks contained no data",ġ43 "successfully collected %d extreme events, found %s no-data blocks",ġ50 index=pd.Index(data=extreme_indices, name=ts.index.name or "date-time"),įile ~/.local/lib/python3.9/site-packages/pandas/core/series.py:439, in Series._init_(self, data, index, dtype, name, copy, fastpath) ValueError Traceback (most recent call last)
