Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
2 answers
106 views

Making a Diagonal matrix with desired shape

How to make a random elements digonal matrix in a numpy array with the desired shape, for example I want to make F to be a numpy array with shape (3, 2, 4, 4), and the diagonal matrix dimensions 4*4 ...
learning statistics 's user avatar
0 votes
1 answer
43 views

How can i add the column name in every sheet of excel file in python

I have 6 sheets in my excel file and i need to copy the date from file name and append the same in every sheet as new column as date.but with this code i can change only in first sheet. import os ...
Gagandeep's user avatar
-2 votes
2 answers
162 views

Sort the coordinates of points by areas that they occupy (Python)

Suppose we have a particular number of points distributed in the plane at the nodes of a grid having a given step. These points form several continuous regions. We can tell that points (if there is ...
Alexander Fedorov's user avatar
-5 votes
2 answers
1k views

In Python in what ways can u make an empty NumPy array? [closed]

(https://i.sstatic.net/eakU9.jpg) To make an empty Numpy the array
Varaprasad Suddala's user avatar
0 votes
1 answer
3k views

How can I read image name from a specific folder?

I want read image name like flower.png unnamed.png. Is there any way that I can read all images images one by one like we can read text file with open ("data.txt", "r") as myfile: ...
M A Nezam Sagor's user avatar
1 vote
2 answers
616 views

timm: typeError: 'builtin_function_or_method' object is not subscriptable

I am implementing timm tutorials on data augmentation to increase the number of images of my dataset. According to their tutorials, I have implemented same code but it did not work. Code import numpy ...
Khawar Islam's user avatar
  • 2,924
-3 votes
1 answer
134 views

How to shuffle a list with specific order ? and i also want user input and simple solution

Write a program to have a function called triple_shuffle () that takes three lists of the same size and shuffles them concurrently. Given list like [10,20,30,40,50], [11,22,33,44,55], and [19,18,17,16,...
Khalilomorph's user avatar
-1 votes
1 answer
60 views

python program to get n unique sequence number within a range

the input is the range and total number needed. consider input range is (0,1) if the total number needed is 10.Then output should be an array containing 10 values between 0 to 1. including 0 and 1. if ...
Uday's user avatar
  • 57
0 votes
4 answers
46 views

I want to compare list of two cities and if list B cities are not present in list A then should append in list A using python

A=['mumbai','delhi','jaipur'] B=['mumbai','kolkata','pune'] I want to compare list A and list B and if list B cities are not in list A then we should able to append those cities in list A
Rohan buks's user avatar
1 vote
2 answers
3k views

Array updating problem for using map(int,input().split()) in python [duplicate]

for taking list input in the array I used map(int,input().split()) but for using this input method I can't modify the array if I Iterated like a[I] then it shows TypeError: 'map' object is not ...
Ahsan Amin's user avatar
0 votes
1 answer
84 views

Syntax Error:Creating An 2d List Filled With Zero

How Could I Initialize An 2D List Filled With Zeroes Without Any Additional Library/Module here what is my attempt table = [0 for i in range(amount + 1)[0 for j in range(len(coins))]] it works in ...
CodeBhiErrorBhi's user avatar
-2 votes
1 answer
325 views

Circular integration Python

I need to calculate this integral in Python: where Etax and rho are arrays calculated at each position in s which is an array representing every point in a circle. My question is how to calculate ...
Esalah's user avatar
  • 27
0 votes
4 answers
3k views

checking two arrays in python which has two same value in an array

I have two arrays and I'm trying to find values ​​that are in the first array but not in the second array. However, there is a problem, although there are two b's in the first array, since there is ...
laika's user avatar
  • 1
-2 votes
1 answer
540 views

How to load the sequence of image in python? [closed]

import S1-T1-C.00000 Image.open('C:/Users/Vims/Desktop/7th sem/ISA/Lab_1/sequence/sequence') I have set of image sequence or video. I would like to load in the python code. How can I do it? After ...
Vims Rocz's user avatar
-1 votes
1 answer
3k views

Write a python program that will take a string as input from the user. The input string should have a combination of BOTH the alphabets and the digits

Write a python program that will take a string as input from the user. The input string should have a combination of BOTH the alphabets and the digits. Then, your task is to identify the digits from ...
Ridwan's user avatar
  • 13
0 votes
1 answer
230 views

Finding non existing fields from an array in another array

I'm writing a code that has 2 python arrays, svslist and prlist. For the purposes of this task, I'm supposed to be finding values that exist in the svslist array but not in the prlist array. So far I'...
stardamore's user avatar
0 votes
0 answers
45 views

how to handle else part in python

Hi I have a code below and want to put 'N/A' in CSV if there is no key is present. tried adding else part after if but getting added N/A values at the end of each row. Can anyone suggest how to handle ...
kiran k's user avatar
  • 41
0 votes
1 answer
3k views

Parsing JSON - TypeError: string indices must be integers

I need to retrieve GoDaddy certificates name and expiration dates. I`m trying code like this: def get_cert(): customerId = "UUID" cert_url = "https://api.godaddy.com//v2/...
Anton's user avatar
  • 1
0 votes
1 answer
43 views

How can I arrange this 3D array data if its randomly written

I have a data for electricity, its arranged as the following room timing 1 timing 2. timing 3 timing 4 timing 5 timing6 1 34.5. 22.1. 34....
alex's user avatar
  • 19
0 votes
4 answers
1k views

how to find 3 Numbers with Sum closest to a given number

I'm trying to write simple code for that problem. If I get an array and number I need to find the 3 numbers that their sum are close to the number that's given. I've thought about first to pop out the ...
user3385217's user avatar
2 votes
2 answers
269 views

How to delete those 1D lists within a 2D list which contains with duplicate 1st element?

Say I have a 2D list(of floats only)- a=[[1,2],[1,3],[2,5],[4,3],[3,4],[4,9]] and I want to remove those 1D lists which have the common 1st element and occur later. For example- the first list [1,2] ...
Manas Dogra's user avatar
0 votes
2 answers
197 views

List within single quotes [duplicate]

I have a list which is in single quotes. '[{"Name":"name1","value":"value1"},{"name":"name2","value":"value2"}]' I ...
Python Charmer's user avatar
0 votes
3 answers
797 views

How do I remove Spaces from nested list created with for loop?

I have created a nested list using for loop. I used the following code: ''' a=[] for i in range(1,5+1): a=a+[[1]*i] print(a) ''' And the output is: How do I remove these spaces before every ...
user avatar
0 votes
1 answer
46 views

how does this line 2d array to 1d array conversion work? [duplicate]

I am able to get it to work but I don't understand how it works li=[[0,1,2],[3,4,5],[6,7,8]] li2 = [ y for x in li for y in x] output: li2: [0,1,2,3,4,5,6,7,8]
new user's user avatar
0 votes
1 answer
4k views

Appending into an empty JSON file in python

I already have a JSON file which I am parsing using Python 2.7 and I want to dump the parsed out data into another empty JSON file. I am using a for-loop to parse out the data from the old JSON file ...
Ashish's user avatar
  • 67
0 votes
0 answers
24 views

Using either a single entry in an array changes result compared to using just a float variable

I'm coding with python2 and trying to convert cartesian coordinates to polar coordinates. Originally I did not care about the original x and y values and so saved over them in every loop of my ...
imjim77's user avatar
1 vote
1 answer
760 views

discord.py commands aren't working (no errors given)

(Code below is just for entertaining purposes only. Do not use this in discord servers). I honestly have no clue why it isn't working. When I open a new python file with the exact same code, it works. ...
fakdofjF FDASJOFADSF's user avatar
0 votes
1 answer
177 views

3 dimensional arrays in python

I am trying to create a 3 dimensional matrix with 400 elements in one dimension and, 4 and 4 in the other two dimensions. I have crated the array as clij_the = np.zeros((400,4,4)) And then I assign ...
FiSer's user avatar
  • 27
0 votes
0 answers
39 views

how to change the data of an array without losing initial data in python? [duplicate]

I am trying to execute this python code below, and i see the data of the 2-d array "grid" , is changing after the fourth print statement. I don't understand why it is changing . can anybody ...
manoj kumar's user avatar
0 votes
2 answers
72 views

Python how to pick 3rd occurence in nested json array

I am working with one of my requirement My requirement: I need to pick and print only 3rd "id" from "syrap" list from the nested json file. I am not getting desired output. Any help will be ...
raj's user avatar
  • 13
0 votes
1 answer
1k views

Converting 2 array objects as key - value pair in JSON object using PYTHON [duplicate]

I have 2 different arrays: dataList = ['a_cout', 'b_count', 'c_count'] dataList1 = [15404, 21381, 3] I am trying to merge them into a json object as Key-Value pair like : '{ "a_count" : 15401, "...
Mayur Shinde's user avatar
0 votes
1 answer
66 views

How can a Python 2.7 string be interpreted as an integer like in C char array?

In C, a character array could be referenced by an int * or cast to be interpreted as an integer value. Here's a small example program: #include <stdio.h> int main() { char *str = "AABB"; ...
Aaron's user avatar
  • 117
0 votes
0 answers
20 views

How can I fix this "The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()"? [duplicate]

I wrote this for comparing two arrays and find #𝑜𝑓|𝑐𝑜𝑒𝑓𝑓𝑖𝑐𝑖𝑒𝑛𝑡𝑠|≥|𝑜𝑏𝑠𝑒𝑟𝑣𝑒𝑑_𝑐𝑜𝑒𝑓𝑓𝑖𝑐𝑖𝑒𝑛𝑡| : count = 0 for a in range(len(coeffs)): for b in range(len(...
Aleyna Buse Sumer Student's user avatar
0 votes
0 answers
39 views

Is a python dictionary the best data type for associating numerical values with a numpy array?

Lets say I have four large numpy arrays (the contents of which don't matter for now): array1 = np.array([stuff1]) array2 = np.array([stuff2]) array3 = np.array([stuff3]) array4 = np.array([stuff4]) ...
Ian Gullett's user avatar
-1 votes
2 answers
73 views

Replacing certain parts of Array in different folders via Pythion

My code does the replacement for the entire file. Whereas I want only certain replacements. Below is the file I'm trying to replace. I just want to change some words in "sheetname" : "...
Rubin's user avatar
  • 31
2 votes
2 answers
647 views

Check for reverse pair repetition in two arrays in python

I have two arrays as follows: a = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5] b = [1, 2, 5, 1, 3, 2, 3, 4, 3, 5, 1, 4] All the possible pairs these two arrays can form are (a[0],b[0]),(a[1],b[1]),(a[2],b[2]...
mango's user avatar
  • 165
1 vote
1 answer
2k views

len() of np.array gives TypeError: len() of unsized object

I need to update a rather large python 2.7 project to python 3. Disclaimer, I'm new to python and this is a task I was given to learn the ins and outs of this language. The tricky part is the ...
Rouben's user avatar
  • 101
0 votes
2 answers
59 views

Is it possible to save 4 variables that hold sliced arrays into a single variable?

(Noob) I have a program that takes an array and slices certain elements depending on their individual functionalities and then arCalc operates on them. Returning all those values from arSlice doesnt ...
John Smith's user avatar
2 votes
0 answers
41 views

Calling modules and passing back data in python

I am running into another issue where when i call a module containing a port scanner that returns an array of open ports, instead getting anything back the application closes. I have tried using ...
NameUnknown's user avatar
0 votes
2 answers
705 views

how can I get json value select from multiple values with python and jq

I have been struggling with json stuff. I have "unit_number" and "key" values and I want to find backing_uuid based on the unit_number and key values. How can I do that with python? I think like this ...
arifisik's user avatar
  • 131
0 votes
2 answers
261 views

Match array of strings to 2D array

I have a 1D array of strings (gene_name_list). I need to find rows in another 2D array (fully_split) where each string of the first array is present. Of course I can solve it brute force like that: ...
Nikita Vlasenko's user avatar
1 vote
2 answers
452 views

Python 2.7: Max digit sum with negative integers

I'm building a program where it takes in n, the size of the array, and an array, A as input. The output should be the index of the integer with largest digit sum I was able to get it to print ...
MCO's user avatar
  • 304
1 vote
1 answer
158 views

Unpacking byte values in Python

I am attempting to unpack the below data but cannot seem to figure it out. This is byte data being returned from a digital sound mixer reading meter values from the device. The documentation suggests ...
J Cross's user avatar
  • 13
1 vote
1 answer
167 views

Parsing JSON with Python, trouble with an array of arrays

I've got a JSON structure that looks like the following { "PersonInformation": { "PhysicalStatus": "", "OpenDetainers": [], "StartDate": "", "FacilityLog": [], "CustStatus": "", ...
Adam vonNieda's user avatar
0 votes
1 answer
919 views

How to overplot in python?

I have a function f(n,x)=n(x+x**2) with 0<=x<=1 and n=0,1,..,9. And using 100 points for x (delx=1/100) would like to over-plot the graph on f(x) for each value of n. These are my codes import ...
Tabucorks's user avatar
0 votes
1 answer
877 views

How to convert an array of Booleans to a string representation?

I'd like to convert imagehash array of booleans like this: array([[False, False, False, True, False, False, True, True], [False, False, False, True, True, True, True, True], [...
Milkyway's user avatar
  • 809
1 vote
3 answers
73 views

Python converting txt in array

I'm reading a .dat file from a samba file server that contains some wind sensor data. That file contains a header with some information (lines 1,3 and 4), a line with sensors names on it (2nd line), ...
dwenzel's user avatar
  • 89
-1 votes
1 answer
2k views

Array convert to string in views django

i have a array in Django views and i want to convert into comma separated string, to save data into DB field like all in one. array[0] = "Ford"; array[1] = "Volvo"; array[2] = &...
Umer Rasheed's user avatar
2 votes
0 answers
45 views

Arrays changing value when saving to / opening h5 files

I am trying to train a CNN classifier in Caffe on image data however when I save my images to h5 format to insert into my first Caffe layer, there is a small chance one or two of my array's will have ...
Matt's user avatar
  • 161
0 votes
1 answer
827 views

Import & Read excel file with Statrtswith any specific string("TRUE")

I am trying import & read Excel file which start with name "TRUE". but actually it complete name is TRUE_management.xlsx import os import pandas as pd files=os.listdir(r'C:\') for f in files: ...
MD SAJID's user avatar
  • 136

1
2 3 4 5
13