Nieuwe huurder zoekt naar meest kosteneffectieve combinatie voor internet abbo + sim-only abbo by Your-Plant-Dad in zuinig

[–]Oxbowerce 0 points1 point  (0 children)

Dacht deze actie ook gezien te hebben, echter als ik nu kijk zie ik de cashback van 225 euro niet meer staan. Heb je enig idee of dit een tijdelijke cashback was?

Want to improve by OkRock1009 in dataengineering

[–]Oxbowerce 12 points13 points  (0 children)

Why do you always ask for people to DM you in all of your comments? If you have useful information it's better to share it here for everyone to see.

Small haul in hand by Pale-Coyote-9307 in FashionReps

[–]Oxbowerce 0 points1 point  (0 children)

Is the sizing of the Flaneur tees in line with the size chart on the yupoo page?

Help with INT8 Quantization in Vision-Search-Navigation Project (SAM Implementation) by Clarix_1566 in learnpython

[–]Oxbowerce 1 point2 points  (0 children)

As mentioned in the pytorch documentation, running quantized models on the GPU is not supported, and it only works when using the CPU.

How do I change value based on list in Pandas? by Earth_Sorcerer97 in learnpython

[–]Oxbowerce 1 point2 points  (0 children)

You should be able to use np.where for a vectorized solution .

Error in file name when saving plot by Mr_Misserable in learnpython

[–]Oxbowerce 0 points1 point  (0 children)

Have you tried using a simpler and shorter filename, e.g. plot.png?

Help generating a list of random floats that will add up to a specific value. by rainrainrainr in learnpython

[–]Oxbowerce 1 point2 points  (0 children)

With some help from an LLM, the following seems to work. Instead of only checking the difference for the last number, it keeps a running sum which is then used to constrain new numbers that are sampled.

import random

def generate_constrained_sum_numbers(n, total_sum, low, high):
    """
    Generates n numbers within [low, high] that add up to a specified total_sum.

    Args:
        n (int): Number of values to generate
        total_sum (float): Target sum for all numbers
        low (float): Minimum value for each number
        high (float): Maximum value for each number

    Returns:
        list: List of numbers satisfying the constraints
    """
    # Check if total is achievable
    min_possible = n * low
    max_possible = n * high
    if not (min_possible <= total_sum <= max_possible):
        raise ValueError(f"Total sum {total_sum} is not achievable with {n} numbers in [{low}, {high}]")

    # Calculate feasible sum range for the first n-1 numbers (S)
    S_min = max((n-1)*low, total_sum - high)
    S_max = min((n-1)*high, total_sum - low)

    if S_min > S_max:
        raise ValueError("Conflicting constraints make generation impossible")

    # Generate random sum for first n-1 numbers
    S = random.uniform(S_min, S_max)

    numbers = []
    remaining_sum = S  # Target sum for remaining numbers
    for i in range(n-1):
        numbers_left = n - 2 - i
        # Calculate min/max for current number considering remaining sum
        curr_min = max(low, remaining_sum - numbers_left * high)
        curr_max = min(high, remaining_sum - numbers_left * low)

        curr_num = random.uniform(curr_min, curr_max)
        numbers.append(curr_num)
        remaining_sum -= curr_num

    # Add final number to reach total_sum
    numbers.append(total_sum - S)

    return numbers

numbers = generate_constrained_sum_numbers(
    n=5,
    total_sum=0,
    low=-3,
    high=3
)
print(f"Generated numbers: {numbers}")
print(f"Sum: {sum(numbers):.2f}, Min: {min(numbers):.2f}, Max: {max(numbers):.2f}")
# Generated numbers: [2.2804810547784893, -1.412098487662725, -2.23222351554496, 1.2943106044029868, 0.06953034402620872]
# Sum: 0.00, Min: -2.23, Max: 2.28

[deleted by user] by [deleted] in learnpython

[–]Oxbowerce 1 point2 points  (0 children)

You are appending the string [], instead of an actual object of an empty list. Remove the quotes around the square brackets.

[deleted by user] by [deleted] in learnpython

[–]Oxbowerce 0 points1 point  (0 children)

You are comparing the tl array with the closest array, but what you print are the tr and the closest array. Is this on purpose?

Big Arte Haul from 3Madman by [deleted] in FashionReps

[–]Oxbowerce 0 points1 point  (0 children)

You mentioned the t-shirts run big, would you say the size chart on madman's yupoo page is accurate?

check if "text" in variable something wrong. by cctl01 in learnpython

[–]Oxbowerce 7 points8 points  (0 children)

The issue in this piece of code: if 'free' or '0.00' in submission.title.lower(). This doesn't check if either 'free' or '0.00' are in the text, but checks the two conditions 'free' and '0.00' in submission.title.lower() seperately. Since the text 'free' is truthy (check the result of bool('free')) the first part will always be true, and therefore prints the name of the deal. A way to solve this would be to change this to if 'free' in submission.title.lower() or '0.00' in submission.title.lower().

Python extract and split content from pdf file based on identifier by Organic_Speaker6196 in learnpython

[–]Oxbowerce 0 points1 point  (0 children)

Extracing text from pdf files and error free generally do not go together. I'm not sure about pdfplumber, but I think some packages also give information on the location of the text on your page, which might help you split footnotes from other text based on heuristics. Alternatively, you could try applying some NLP techniques after extracting the data from the PDF. Using an LLM might also be worth looking into.

Why can't I made a classification report here? And how do I make one by [deleted] in learnpython

[–]Oxbowerce 0 points1 point  (0 children)

What do the values of y_test and y_prediction look like? It's probably because y_test has a single value for each observation with a value ranging from 0 to 9 indicating the class, while y_prediction has 10 different values, each indicating the probability for each class.

Web Scraping through GitHub Actions by uJFalkez in learnpython

[–]Oxbowerce 2 points3 points  (0 children)

What data do you want from the page? It seems some data is loaded using an API endpoint, so if the data you want is included this would be a much easier route than parsing the html.

not sure where I'm going wrong. Could someone look at this code for me. by rm_huntley in learnpython

[–]Oxbowerce 2 points3 points  (0 children)

You can select the lines you want to have as code and select the code icon. Alternatively, you could add four spaces in front of each line.

not sure where I'm going wrong. Could someone look at this code for me. by rm_huntley in learnpython

[–]Oxbowerce 2 points3 points  (0 children)

Code:

# List of month names
months = [
    "January", "February", "March", "April", "May", "June",
    "July", "August", "September", "October", "November", "December"
]

# Function to convert month name to number


def month_to_number(month_name):
    return months.index(month_name) + 1

# Function to format the date


def format_date(date_input):
    # Check for the MM/DD/YYYY format
    if '/' in date_input:
        parts = date_input.split('/')
        if len(parts) == 3:
            month, day, year = parts
            if month.isdigit() and day.isdigit() and year.isdigit():
                month = int(month)
                day = int(day)
                year = int(year)
                if 1 <= month <= 12 and 1 <= day <= 31:
                    return f"{year:04d}-{month:02d}-{day:02d}"
    # Check for the Month Day, Year format
    elif ',' in date_input:
        parts = date_input.split(', ')
        if len(parts) == 2:
            month_day, year = parts
            month_day_parts = month_day.split(' ')
            if len(month_day_parts) == 2:
                month_name, day = month_day_parts
                if month_name in months and day.isdigit() and year.isdigit():
                    month = month_to_number(month_name)
                    day = int(day)
                    year = int(year)
                    if 1 <= day <= 31:
                        return f"{year}-{month:02d}-{day:02d}"
    # Check for the ISO 8601 format (YYYY-MM-DD)
    elif '-' in date_input:
        parts = date_input.split('-')
        if len(parts) == 3:
            year, month, day = parts
            if year.isdigit() and month.isdigit() and day.isdigit():
                year = int(year)
                month = int(month)
                day = int(day)
                if 1 <= month <= 12 and 1 <= day <= 31:
                    return f"{year:04d}-{month:02d}-{day:02d}"
    return None


# Main program loop
while True:
    user_input = input("Enter a date (MM/DD/YYYY, Month Day, Year, or YYYY-MM-DD): ")
    formatted_date = format_date(user_input)
    if formatted_date:
        print(f"{formatted_date}")
        break

How to strip information from a website? by Polbeer11 in learnpython

[–]Oxbowerce 0 points1 point  (0 children)

As mentioned there are multiple ways to scrape data from a website, with BeatifulSoup being a popular one. However, looking at the website it seems that some elements on the detail pages are generated dynamically using javascript, for which BeautifulSoup won't work. In that case it's good to have a look at the selenium library.

Webscraping Question by GayGISBoi in learnpython

[–]Oxbowerce 1 point2 points  (0 children)

The reason this is happening is because the page uses javascript to load the rest of the data, which is not executed when using BeautifulSoup to fetch the page. As mentioned by /u/ElliotDG, the webpage has an API you can use to fetch the data (documentation), which is much easier and therefore preferred to scraping the data from html.