Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: from numpy array to csv - rounding
Post: RE: from numpy array to csv - rounding

(Nov-14-2022, 08:25 PM)deanhystad Wrote: Curious though, why do you want to round floats to 3 digits in a csv file? It's not like csv is a presentation format. I want to lose precision so that the ...
SchroedingersLion General Coding Help 6 2,164 Nov-14-2022, 08:52 PM
    Thread: from numpy array to csv - rounding
Post: RE: from numpy array to csv - rounding

Thank you, you two! I just found another way. Apparently, numpy offers a rounding function for their arrays, so one can just call ARR.round(decim)where ARR is a numpy array to be rounded to decim si...
SchroedingersLion General Coding Help 6 2,164 Nov-14-2022, 07:08 PM
    Thread: from numpy array to csv - rounding
Post: from numpy array to csv - rounding

Greetings, I have a 2D numpy array ARR storing a bunch of floats. I want to print it row by row to a .csv file, but rounded to 3 significant digits. Is there a simple way to do this? This is what I c...
SchroedingersLion General Coding Help 6 2,164 Nov-14-2022, 05:33 PM
    Thread: matplotlib x-axis wrong order
Post: RE: matplotlib x-axis wrong order

Thanks guys! The thing is that the second half of my batches are batches from a following epoch. Earlier in the document, they were labelled from 0 to 134 again, which is why I would like my x-axis t...
SchroedingersLion General Coding Help 4 4,254 Feb-23-2021, 05:11 PM
    Thread: matplotlib x-axis wrong order
Post: matplotlib x-axis wrong order

Greetings! I would like to create a simple 2D plot of 270 data points. batchnrs = list(range(0,135))*2 plt.plot(batchnrs, loss_per_batch, label="loss") plt.show()However, the x-axis in the plot does...
SchroedingersLion General Coding Help 4 4,254 Feb-18-2021, 03:59 PM
    Thread: append list to empty array
Post: RE: append list to empty array

I found the solution: One has to specify axis=0 in order to get what I want, otherwise the arrays are flattened before appending is performed. X_y_disch = np.append(X_y_disch, [[k for k in B1_B2[keys...
SchroedingersLion General Coding Help 1 2,169 Feb-02-2020, 05:29 PM
    Thread: append list to empty array
Post: append list to empty array

Hello guys, I would like to know why the following does not give me an Nx7 array. X_y_disch = np.empty((0,7), float) for keys in B1_B2: X_y_disch = np.append(X_y_disch, [[k for k in B1_B2[keys][...
SchroedingersLion General Coding Help 1 2,169 Feb-02-2020, 01:57 AM
    Thread: inserting something into probability density
Post: inserting something into probability density

Hi guys, I need to insert a vector X into the multivariate normal distribution (WIKI), and get its value. I know that numpy offers sampling from this distribution, but can I also insert a vector and...
SchroedingersLion Data Science 1 2,116 Jan-05-2020, 11:15 PM
    Thread: change array elements dependent on index
Post: change array elements dependent on index

Greetings, is there an easier way to write the following with some kind of slicing arithmetics? for k in range(1, N-1): A[k] = some_function(k) * some_array[k]where A and some_array are numpy ar...
SchroedingersLion General Coding Help 1 2,205 Nov-21-2019, 09:52 PM
    Thread: zooming in pyplot window
Post: zooming in pyplot window

Hi guys, I am a bit confused by the axis labeling that appears when I zoom-in in a typical 2D plot window. Suppose I am in the region of x<0. I zoom in again and again. Of course, the units of the...
SchroedingersLion Data Science 0 2,196 Aug-02-2019, 02:59 PM
    Thread: reading in csv row by row
Post: RE: reading in csv row by row

Guys, please... I want to use csv reader to read in my data as stated. I am in a deep hurry and I don't have the time to think about the equivalency of different implementation methods. I have learne...
SchroedingersLion Homework 9 5,645 Jan-08-2019, 10:47 PM
    Thread: reading in csv row by row
Post: RE: reading in csv row by row

(Jan-08-2019, 07:18 PM)woooee Wrote: Using csv.reader only complicates this IMHO ## obviously we don't have this file, so this is untested code x_training = [] y_training = [] data = open(csv_file...
SchroedingersLion Homework 9 5,645 Jan-08-2019, 07:23 PM
    Thread: reading in csv row by row
Post: reading in csv row by row

Good evening, can someone help me with the syntax in saving the rows of a csv files with M rows and N columns into a list? I do not want the last column, but all of the M rows. Thus, the list should ...
SchroedingersLion Homework 9 5,645 Jan-08-2019, 07:01 PM
    Thread: writing numbers to csv file
Post: RE: writing numbers to csv file

Thank you, I will give it a try this afternoon!
SchroedingersLion General Coding Help 7 4,045 Dec-19-2018, 12:53 PM
    Thread: writing numbers to csv file
Post: RE: writing numbers to csv file

(Dec-19-2018, 11:33 AM)buran Wrote: with open(outputname, mode='w') as csv_output: result_writer=csv.writer(csv_output, delimiter=" ") # option 1 for nums in zip(x2, y2): ...
SchroedingersLion General Coding Help 7 4,045 Dec-19-2018, 12:31 PM
    Thread: writing numbers to csv file
Post: writing numbers to csv file

Greetings, can someone tell me wether the following is correct? I have float values stored in two lists, namely x2 and y2. I want to print a csv file with delimiter " ", in which the i-th element of ...
SchroedingersLion General Coding Help 7 4,045 Dec-19-2018, 10:51 AM
    Thread: draw sample from distribution in interval
Post: RE: draw sample from distribution in interval

Ah, I got my error. Aside from my inexperienced Python coding, my mathematical method was flawed.
SchroedingersLion Homework 2 2,471 Oct-28-2018, 10:23 PM
    Thread: draw sample from distribution in interval
Post: RE: draw sample from distribution in interval

from scipy.stats import beta n=10000 #sample sizes sample_theta1=[beta.rvs(91,11) for x in range(n)] beta_values_theta1=beta.pdf(sample_theta1,91,11) summands_total_integral=[] sample_theta2=[] beta...
SchroedingersLion Homework 2 2,471 Oct-28-2018, 03:46 PM
    Thread: draw sample from distribution in interval
Post: draw sample from distribution in interval

Greetings, I am trying to numerically calculate a double integral over probability distributions (beta distributions), see picture. I want to approximate the integrals as sums, taking samples accordi...
SchroedingersLion Homework 2 2,471 Oct-28-2018, 02:32 PM
    Thread: dividing by list not possible?
Post: RE: dividing by list not possible?

Thank you guys! Almost forgot about the thread, sorry! @volcano63 So if I want to use these elementwise array operations, I have to make sure that I am using an actual "numpy array" and not the stand...
SchroedingersLion Data Science 5 3,813 Oct-11-2018, 09:00 AM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020