Irrationalmachine

u/Irrationalmachine


r/learnpython•

I keep getting this error "ValueError: operands could not be broadcast together with shapes (1,2000) (10)" with this code and I'm not sure what it means or why I am getting it.
Any help is very much appreciated!

In:

    print numeric_sample_target.dtype
    print numeric_sample_target[:10]
    print numeric_sample_target.shape
    print ''
    print sample_data.dtype
    print sample_data[:10]
    print sample_target.shape

Out:

    int32
    [1 2 2 2 2 2 2 2 2 1]
    (2000,)
    
    int64
    [[  87    1    0    0   41    0    0    0    0  290]
     [  87    0    3    0    2    0    0    0    0  647]
     [
92

r/learnpython•

How would I find the number of days between the current date and df['date'] and create a new column with the results.

date       count    user      days_since 
2013/02/22  145      apple      ###
2005/01/16  234      banana     ###
2011/02/01  521      orange     ###
2001/01/14  10       grape      ###

Thanks!

13

r/learnpython•

Hi, I have some binned data and I would like to fit a curve to it and then plot both the curve and the bar graph.

dist[:10]

(0, 500]        512
(500, 1000]     408
(1000, 1500]    226
(1500, 2000]    112
(2000, 2500]     83
(2500, 3000]     42
(3000, 3500]     18
(3500, 4000]     17
(4000, 4500]     14
(4500, 5000]      6

How would I use scipy.optimize.curve_fit to accomplish that? Something like this:

bin_centre = {250,750,1250,1750,2250,2750,3250,3750,4250,4750}
popt, pcov = curve_fit(bin_centre, dist[:10])  

Thanks!

23

r/learnpython•

So, I have some irregular data that looks like this:

x = "35 minutes, 15 seconds, 3 seconds, 15 min, 5 minutes, NaN 30 minutes, 8 to 10 mins"

I'm using a few regexs to deal with the units but am stuck on converting a list to floats so I can divide the min times by 60 to have everything in hours.

def durConverter(x): numbers = (re.findall('[0-9]+',str(x)))
results = float(numbers[:1])
print type(results)

I would expect results to be floats now.
I get the error "TypeError: float() argument must be a string or a number"

So I changed the 3rd line to:
results = float(str(numbers[:1]))
and I get the error "ValueError: could not convert string to float: []

08

The question is: "A rectangle ABCD has A and D on the equal sides of an isosceles triangle and B and C on its base. If AB=2cm and BC=6cm, find the value of θ [bottom right corner of the triangle] that produces a triangle of minimum area."

I keep getting θ=1.89Rad, but it does not seem right. Can someone show me their process for solving this?

Thanks!

17


r/AskNetsec•

I've found something that looks like it will take an injection, at work, but I am having trouble figuring out where to go from here.

"http://www.somesite.com/WebService/MemberProfileService.asmx?op=GetOnlineBuddies&profileId=3419&sessionId=d'z"0".

Outputs:

System.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'SITE_FEATURE_USAGETYPESIDFK', table 'SOMESITESecondary.dbo.USER_SESSION_FEATURE_SETTINGS'; column does not allow nulls. INSERT fails.
The statement has been terminated.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnect

03

Q: Find the number of solutions of the equation 3x + 4y = 229, if x and y must be positive integers.

For this counting problem I can follow the steps to solve it but I do not understand why/how they work. Can someone please step me through the problem with a bit of commentary. Thanks!!

34

r/javahelp•

I'm trying to pull a seven digit number out of a string of text. I only need the number but the text before and after it will change every time. I'm reading the html in line by line but need to only get the second 7 digit number from this string

</td><td align="left" width="15%" class="text"><a CLASS="Bcruising" HREF="&#xA; javascript:EditMember(2566802,2966456)&#xA; ">Usernamexxx</a>

I would use this command in bash "egrep -o '[0-9]{7}' " and am looking for something similar in java.

Any help would be very appreciated :)

42



You've reached the end of this feed.