user02

-1

votes
0

answer
14

views

sum the minimum of the column when the column contains a negative value

I have a dataframe like this idx A B C D 1 0.01 0.01 0.03 0.01 2 -0.01 -0.02 0.04 -0.01 3 0.02 -0.03 0.02 0.05 4 0.03 0.01 0.01 0.01 What I need to do is shifting all the series by their minimum value, when the series contains a negative value. I w...
user02
1

votes
1

answer
3.3k

views

Python- combine two lists to make a list of lists [duplicate]

This question already has an answer here: How to declare and add items to an array in Python? 7 answers What is the syntax to insert one list into another list in python? 5 answers Split list into different variables 1 answer I want to combine two lists into a list of lists. And vice versa. I can...
user02
2

votes
3

answer
54

views

Calculate distances in multi-dimensional matrix

I wrote this code to calculate the distance. But getting error of ValueError: math domain error. import math a=[[5, 10], [16, 23]] b=[[6, 1], [21, 2]] dL=[] dist=[] k=0 h=1 for i in range(len(a)): dL=[] for j in range(len(a)): d=math.sqrt((a[i][k]-b[j][k])^2 + (a[i][h]-b[j][h])^2) dL.append(d) dist....
user02
8

votes
4

answer
199

views

Python- Removing items

I want to remove item from a list called mom. I have another list called cut mom= [[0,8,1], [0, 6, 2, 7], [0, 11, 12, 3, 9], [0, 5, 4, 10]] cut =[0, 9, 8, 2] How do I remove what in cut from mom, except for zero? My desire result is mom=[[0,1],[0,6,7],[0,11,12,3],[0,5,4,10]]
user02
3

votes
1

answer
202

views

How to convert nested list of numbers to list of strings?

I have a list of lists below p=[[1,2,3,4],[2,3,4,1]] How do I put the sublist into a string? For example, desire result is: p=["1234","2341"]
user02