Posts by Sofia Raimundo • 537 points
16 posts
-
1
votes1
answer2369
viewsQ: Read excel information in matrix form with python
I’m using Python 2.7 to read values from an Excel document. When I have only one row of values with respective header I can read, doing from openpyxl import Workbook from openpyxl import…
-
5
votes1
answer480
viewsQ: Python lists and dictionaries
I’m working on Python 2.7. import collections counter_ger=collections.Counter(sub_todaas) a=counter_ger.values() b=counter_ger.keys() sub_ind_novo = [Ntodos.index(i) for i in b if i in Ntodos]…
-
9
votes2
answers1356
viewsQ: Convert a list list into a single list
I’m working on Python 2.7. I have this result: Resultado=[['A','B','C'],['D','E','F'],['G','H','I']] How can I turn this into a list? And get the following:…
-
0
votes2
answers560
viewsQ: List indexes in python
Good afternoon! I have the list: a=[4,3, 1, 2, 3] and the list: sub_ind_novo=[96, 7, 97, 23, 18] And I needed to link the lists by getting the result: no97. G1 #when sub_ind_novo is 97, the…
-
3
votes3
answers479
viewsQ: Maximum occurrences in a python dictionary
If I have the dictionary: meu_dic = {A:3, B:5, C:0, D:10, E:2} resulting from: meu_dic = {i:lista.count(i) for i in lista} I know that To appears 3 times in the list, B 5 times, etc.. How can I…
-
8
votes4
answers485
viewsQ: How to determine the index of items in one list in another
Work with python 2.7. Whereas the following: S_names=["A", "B", "C", "D", "E", "F", "G"] S_values=[1,3,4,2,5,8,10] other=["Z","W","B","S","A","E","X","T","D","G","L","C","F"] I need to find in what…
-
4
votes1
answer86
viewsQ: How to get an end list for the start?
Opening lists: B_I = ['Cab', 'Bou', 'Bou', 'RFF', 'RF1', 'Rf2', 'Cor'] Ba_F = ['Bou', 'Zez1', 'Zez2', 'Praca', 'Sro', 'Sro', 'Falag'] Then I did ........ Final=[] #lista com todos os barramentos sem…
-
-1
votes1
answer73
viewsQ: list indexes
My two initial lists have repeated values: B_I=[Cab, Bou, Bou, RFF, RF1, Rf2, Color] Ba_f=[Bou, Zez1, Zez2, Praca, Sro, Sro, Falag] I eliminated the repeaters, leaving with: Final=[Cab, Bou, RFF,…
-
1
votes1
answer1198
viewsQ: Remove duplicates from a list keeping order
I had the list: A = [12, 15, 10, 15, 12, 10, 10, 10, 15, 12, 12, 15, 15, 15] , in making: ASemRepetidos=set(A) get ([10, 12, 15]), as it turns out, whether in A my first element is 12, in set(A)…
-
0
votes1
answer131
viewsQ: Initial input of a list after using set
I used this code initially to aggregate in dictionaries the values of B which had equal value in A: A = [12, 15, 10, 15, 12, 10, 10, 10, 15, 12, 12, 15, 15, 15] B = [0.2, 0.3, 1.1, 0.2, 0.2, 0.7,…
-
1
votes2
answers272
viewsQ: Items of B whose indices are the positions of occurrences of equal elements in A
If I have the lists: A = [12, 15, 10, 15, 12, 10, 10, 10, 15, 12, 12, 15, 15, 15] B = [0.2, 0.3, 1.1, 0.2, 0.2, 0.7, 0.4, 0.6, 0.1, 0.3, 0.7, 0.4, 0.5, 0.5] How can I group in separate lists the…
-
4
votes3
answers1388
viewsQ: Minimum search from a list ignoring zero values
I have a list of values with zero elements and elements other than zero and I wanted to return the lowest value of the list and its Index, but ignoring the zeroes, that is, the fact that there are…
-
0
votes3
answers115
viewsQ: Multidimensional array
I am trying to create a multidimensional array. I first intended to place all the first elements with value 2 so I did: l=4 x=6 TSup=[ [ 2 for i in range(l) ] for j in range(x) ] print TSup and I…
-
0
votes0
answers64
viewsQ: Undefined variable error
I have this code and it tells me that Spec is not defined in (pcolor(freq,tstart,Spec);colorbar), but I am calculating it in the cycle.. Does anyone understand why the mistake? Thank you! N…
matlabasked Sofia Raimundo 537 -
1
votes1
answer23293
viewsQ: list index out of range
Tsup=[] Te=0 dt=1 t=range(0,3600*2,dt) r=len(t) for i in range(0,r): Tsup.append(20) .... Tsup.append( (((Pj[i]+Ps-Pc[i]-Pr[i])*(dt))/((m_al*c_al[i])+(m_a*c_a[i])))+Tsup[i] ) if i==r:…
-
4
votes1
answer13184
viewsQ: assignment list index out of range
Part of my Python program is: dt=1 maxt=3600*2 t=range(0,maxt,dt) r=len(t) Tsup_i=20 for i in range(1,r): Tsup[0]=Tsup_i P[i]=((I_dc)**2) * R20 * (1 + a * (Tsup[i] - (20+K))) And the error is…