Skip to main content

All Questions

Tagged with
-1 votes
1 answer
54 views

Generate and loop through pairs in a code block [duplicate]

I am trying to generate a list of unique pairs from two ranges. I then want to use this list of unique pairs as part of a URL in a loop to download a large batch of data. I have managed to generate my ...
Stephen Washburn's user avatar
0 votes
1 answer
70 views

Creating a 'for' or 'if-else' selector for checking dynamically sized python List

I'm trying to mask 8752 images with transformers like this from transformers import pipeline from PIL import Image import requests import cv2 import numpy as np from matplotlib import pyplot as plt ...
RedSean's user avatar
  • 47
1 vote
2 answers
91 views

Looping if statement

I want to loop through an array with an if statement and only after it has looped through the entire array execute the else. This is how i have my code now for index, nameList in enumerate(checkedName)...
PaN1NI's user avatar
  • 29
0 votes
0 answers
37 views

Finding the VIF of Standardized Variables in python

import numpy as np import pandas as pd import statsmodels.api as sm import matplotlib.pyplot as plt from sklearn.linear_model import LinearRegression import seaborn as sns sns.set() from ...
h2lawal's user avatar
0 votes
0 answers
30 views

How to get a third dimension in xarray from loop values?

I have a climatology data array for 41 years over the winter period (defined as November 1 - March 31). From this climatology Xarray DataArray (with over 6,000 days/values), I have grouped the days ...
humanoid_physics's user avatar
0 votes
0 answers
27 views

How to populate a matrix assigning values based on placeholders?

I have a matrix populated with letters as placeholders. I need these letters to be substituted with integers ranging from 0 to 9. Each of these integers will correspond to one digit of a number formed ...
marty's user avatar
  • 1
0 votes
0 answers
129 views

Loops - Why is my solution so much slower for hackerrank new year chaos?

I was doing the hackerrank "new year chaos" problem. Here is the description: It is New Year's Day and people are in line for the Wonderland rollercoaster ride. Each person wears a sticker ...
user12138762's user avatar
0 votes
1 answer
250 views

How can I loop faster over an array using Cython?

I have an optics tool in which i need to calculate a set of complex amplitudes (i.e. wavefronts) for a range of time steps and wavelengths. So essentially I have two for loops and for each item I have ...
Phil's user avatar
  • 11
0 votes
2 answers
445 views

I am trying to find a way to act on characters in an array in Python

I am very new to coding and Python. I am trying to change characters in string elements of an array conditional on their adjacency to another character. These characters are grouped into arrays based ...
Usergyt's user avatar
0 votes
1 answer
132 views

Append elements to different lists based on if-else statements in python

I have been trying to create the following program in Python. However, I am getting frustrated with my program, and I have no idea what I should be doing! Specifically, I am having trouble appending ...
Selah's user avatar
  • 3
-1 votes
2 answers
54 views

Python String Comparisons, why does x for x not work with list of lists

I am trying to get a value out of a list of array of strings based on another value in the same array. zone = [x for x in zoneList if (x[2] == usageRow[2])][1] This is not part of the code, just a ...
Donald Deutscher's user avatar
0 votes
2 answers
47 views

How to add two numpy arrays by comparing element size?

I have two numpy arrays in python: a = np.array([1, 7, 2, 10, 5]) b = np.array([1, 5, 3, 4, 1]) I want to add these two arrays such that the final array has sum elements only if the element of array ...
noob anomaly's user avatar
0 votes
4 answers
103 views

What am I doing wrong in this Pascal's triangle generator?

I am trying to print Pascal's triangle using Python. I am using nested lists and loops. It works something like this. For n = 2 it should print: 1 1 1 1 2 1 This is my code: n = int(input("...
Zey Roax's user avatar
0 votes
0 answers
52 views

Iterating through 3D numpy arrays

I am trying to write a memory efficient code for iterating through 2 three-dimensional numpy arrays. Consider the following example: First array is 3 dimensional for global NDVI (LAT, LON, TIME) ...
Dávid D.Kovács's user avatar
1 vote
0 answers
80 views

array populated from a loop gets overwritten

I have the following code - I am parsing a dataframe and creating lists from subsets of data found in the dataframe. I then transform the lists into arrays as I'd like to do further treatment (later ...
gt89's user avatar
  • 11

15 30 50 per page
1
2 3 4 5
49