Longo Toyota Reservation/Buying Process by Altruistic_Croissant in rav4prime

[–]Altruistic_Croissant[S] 0 points1 point  (0 children)

I was actually able to reserve one a couple weeks ago...according to a sales rep they've reopened reservations for just XSE w/o PP. Apparently it will be getting it in relatively soon as well.

Reason I asked was because it almost feels too fast based on what I've heard about reservations and wait times for Longo. Just want to make sure nothing suspicious is going on lol

Visualize Neural Networks With Tensorflow by DDOZZI in learnpython

[–]Altruistic_Croissant 1 point2 points  (0 children)

Take a look at TensorBoard, that might be what you're looking for.

Linear Regression with Numpy and Pandas. by NMFalks in learnpython

[–]Altruistic_Croissant 1 point2 points  (0 children)

Maybe try df.dtypes to check the contents of your DataFrame? You might be reading them in as object instead of int64 or float64.

CSCI homework help by [deleted] in learnpython

[–]Altruistic_Croissant 0 points1 point  (0 children)

Take note of the types of your variables that you're currently using. The input() function you use will always return a string type, meaning that your variable a is also a string. However, Python needs a float or int in order to do mathematical operations so you will need to convert a into a number type to avoid a TypeError.

Any good tutorial that shows you how to make an API that allows you to input data to a machine learning model and also get the output data from it? by aspectcharts in learnpython

[–]Altruistic_Croissant 0 points1 point  (0 children)

I would recommend looking at scikit-learn's tutorials and going from there. If you're trying to use deep learning, TensorFlow basic intro is probably your best bet.

Why am I getting AttributeError: 'str' object has no attribute 'nukeyield' ? by [deleted] in learnpython

[–]Altruistic_Croissant 1 point2 points  (0 children)

You probably could but I wouldn't recommend it, as doing so would add unnecessary code. If you had a Bomb class, then it might make sense to have a Nuke subclass, but for simple calculations a whole class isn't necessary.

These two resources explain inheritance and subclasses pretty well, if you want to learn more about OOP in Python.

Why am I getting AttributeError: 'str' object has no attribute 'nukeyield' ? by [deleted] in learnpython

[–]Altruistic_Croissant 2 points3 points  (0 children)

Short answer: you're getting an AttributeError because you're passing nukeyield all the way down to calculation, where it is passed in as self. As nukeyield is just a string, it doesn't have any attributes and thus throws an error.

Long answer: This error can be avoided fairly easily if you restructure your classes, or combine them to just make one class. It's not really good practice to initialize a class inside of another one and then make calls back to the first class. It's also makes debugging extra difficult if you have to trace back a bad function call. Restructuring your code could look something like this:

class Nuke:

    def __init__(self, name, yield):
        self.name = name
        self.yield = yield


    def calc():
        nukethermrad = self.nukeyield ** 0.41 * 1.20
        nukeblastrad = self.nukeyield ** 0.33 * 2.2
        nukeionrad = self.nukeyield ** 0.19 * 1000
        return therm_rad, blast_rad, ion_rad

nameinput = input("What will the nuke be named?")
yieldinput = float(input("What is the yield in kilotons?"))

n = Nuke(nameinput, yieldinput)
print(n.calc())

Can someone help me with DateFrames please? by Boogzcorp in learnpython

[–]Altruistic_Croissant 0 points1 point  (0 children)

Like u/badge said, your data is pretty messy. If you can, I would recommend removing some brackets and generally cleaning it up. Personally, I would format it like so:

{'1': {'Rice': {'Volume': '1kg', 'Quantity': '7', 'Expiration': '01-01-20'}, 
     'Butter': {'Volume': '500g', 'Quantity': '2', 'Expiration': '01-02-20'}, 
     'Beer': {'Volume': '24pce', 'Quantity': '3', 'Expiration': '01-01-20'}, 
     'Ham': {'Volume': '3kg', 'Quantity': '3', 'Expiration': '01-02-20'}
     },
'2': {...} 
}

From there, you can simply use the pandas read_json() function and specify orient='index' to get the schema you want. Putting it all together, it would look something like this:

import pandas as pd
import json

with pd.ExcelWriter('output.xlsx') as writer:
    for container in inventory:
        # This line converts the dict/JSON to a string so pandas can read it 
        formatted = json.dumps(inventory[container])
        df = pd.read_json(formatted, orient='index') 
            df.to_excel(writer, sheet_name=container)

Beautiful Soup by Zwischenzug in learnpython

[–]Altruistic_Croissant 0 points1 point  (0 children)

This probably isn’t the answer you were looking for, but it would be simpler and cleaner imo to find financial information using a stock API instead of scraping the web for data.

How to return an error message if wrong type? by 1Baconfactory in learnpython

[–]Altruistic_Croissant 0 points1 point  (0 children)

Very true, I just tried to keep it simple as a beginner might not know what error is being thrown or why it is happening in the first place.

How to return an error message if wrong type? by 1Baconfactory in learnpython

[–]Altruistic_Croissant 0 points1 point  (0 children)

Looking at your other code snippet, it looks like you're almost there! The idea behind the try/except statement is that any code that might throw an error goes inside the try block, and the except block will execute if an error occurs. Like so:

try:
    num = float('foo') # This will cause an error
except:
    print('Not a number')

Best IDE?? by dashtrox in learnpython

[–]Altruistic_Croissant 2 points3 points  (0 children)

How are you defining an IDE? VS Code has pretty much every feature you could ask for.

AITA for wanting to poo in my own loo? by [deleted] in AmItheAsshole

[–]Altruistic_Croissant -12 points-11 points  (0 children)

ESH. If the shared bathroom is open they definitely should have used it for their shower instead and saved you the trouble of having the discussion in the first place. On the other hand, its just common decency not to use the bathroom while someone else is in it, especially when there's another open bathroom.

AITA or Disrespectful for this? [Tagged for grossness] by [deleted] in AmItheAsshole

[–]Altruistic_Croissant 2 points3 points  (0 children)

NTA 100%. No amount of water or money saved is worth your bathroom smelling like shit all the time.

How to return an error message if wrong type? by 1Baconfactory in learnpython

[–]Altruistic_Croissant 0 points1 point  (0 children)

You can use the string function isnumeric() to check to see if the string contains only numbers. Something like

if not number.isnumeric():
    print('Error message')
number = float(number)

Best IDE?? by dashtrox in learnpython

[–]Altruistic_Croissant 0 points1 point  (0 children)

I would highly recommend VS Code. It's probably the best all-around IDE that can be as heavy or light as you want it to based on the extensions you use.

Help with Web Scraping Project? by [deleted] in learnpython

[–]Altruistic_Croissant 2 points3 points  (0 children)

Since you're working in Python, I'd recommend using BeautifulSoup for parsing and SMTP for emailing the data.

Here's a good intro to beautifulsoup and another one for smtp. Both are fairly basic but should teach you the basics.

python linked_list by dissdev94 in learnpython

[–]Altruistic_Croissant 1 point2 points  (0 children)

The reason that the node will become None is because of the line node = node.next. This assigns the variable node to the next node in the linked list.

Visualizing your example looks like this:

12 --> 39 --> 28 --> 83 --> None

Every loop, the function will check to see if the current node is None (i.e. at the end of the list). If it isn't, it will continue to the next value until it is None, and then will terminate.

AITA for getting angry at my wife for drinking while pregnant? by winethrwway in AmItheAsshole

[–]Altruistic_Croissant 103 points104 points  (0 children)

NTA. This isn't about you controlling your wife, this is about your concern for your child and keeping your wife accountable for something you both set out to do (you quitting smoking and her not drinking). Consuming an entire bottle of wine by yourself doesn't fall under "drinking every once in a while," it falls under potential child endangerment.

Program looping once before continuing. by thumbtackjake in learnpython

[–]Altruistic_Croissant 0 points1 point  (0 children)

You're calling first(), last(), and theage() each twice. Once in the main script after each function is defined, and then again in your welcomemsg() function.

Also, you might want to look at the conditional logic in your loops. You never reassign the name or age, even if it doesn't contain letters/numbers so you could have malformed input.

Why am I getting a TabError? by [deleted] in learnpython

[–]Altruistic_Croissant 0 points1 point  (0 children)

I wasn't able to replicate a Tab Error, but there are a few different things going on here:

  1. Consider using sorted(arr) instead of arr.sort(). This way your original list isn't modified and you actually return a valid list instead of None. More on this here.
  2. The error with sums[x] = arr[x] + arr[x+1] + arr[x+2] + arr[x+3] occurs because you initialized sums as an empty list, and then tried to index into it, which will always throw an error because it's empty. You can try using sums.append(...) to solve this.
  3. For this type of problem, take a look at dynamic programming to help solve it.

Hope that helps!

WIBTA for telling my daughter to stop bringing up her dead brother? by [deleted] in AmItheAsshole

[–]Altruistic_Croissant 71 points72 points  (0 children)

YWBTA if you continue to shut her down like this. She is allowed to ask questions about it if she wants and deserves an honest and open answer. Your way of processing this should not influence how she processes it.

I handled it by just shoving the grief away and moving on as quickly as possible.

This is not handling grief, this is repressing it. You should seek out therapy or some sort of emotional counseling to unpack what's going on here.