#๐ Python help
80 messages ยท Page 1 of 1 (latest)
@oblique crest
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
plant_50614_generators = []
for idx in range(num_rows):
plant_id = cell(idx, 'plant_id')
technology = cell(idx, 'technology')
generator_id = cell(idx, 'generator_id')
# Check if plant_id is 50614 and technology is "Wood/Wood Waste Biomass"
if plant_id == "50614" and technology.lower() == "Wood/Wood Waste Biomass":
plant_50614_generators.append(generator_id)
plant_50614_generators = sorted(plant_50614_generators, reverse=True)
Display the result
plant_50614_generators
Hey @oblique crest!
It looks like you're trying to paste code into this channel.
Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.
To do this, use the following method:
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
You can **edit your original message** to correct your code block.
You're not printing anything out.
iirc jupyter notbook lets you just say the variable name to print in the console
TIL, thanks.
So what should I do
so in this if
you are doing .lower() but your string to compare isnt lowered
@oblique crest What's in technology?
Ohh
Wood/Wood... should be wood/wood...
That will never be true
i just changed it and it still didnt work :((
try to remove the "" from the plant_id == ...
def cell(row_idx, col_name):
col_idx = csv_header.index(col_name)
val = csv_rows[row_idx][col_idx]
if val == " ":
return None
int_columns = ['entity_id', 'plant_id']
float_columns = ['net_summer_capacity', 'net_winter_capacity', 'latitude', 'longitude']
if col_name in int_columns:
return int(val)
elif col_name in float_columns:
return float(val)
else:
return val
remove the quotations?
could u show it
ok
but my other ones
have the quotes
see like my definition here it uses a quotation around the entity name
plant_50614_generators = []
for idx in range(num_rows):
plant_id = cell(idx, 'plant_id')
technology = cell(idx, 'technology')
generator_id = cell(idx, 'generator_id')
# Check if plant_id is 50614 and technology is "Wood/Wood Waste Biomass"
if plant_id == 50614 and technology.lower() == "wood/wood waste biomass":
plant_50614_generators.append(generator_id)
plant_50614_generators = sorted(plant_50614_generators, reverse=True)
# Display the result
plant_50614_generators
Lmaooooo
try to run this
you are maybe confused about the primitive types of python
number = 50614 # this is a int
another_number = 12.34 # this is a float
text = "this is a string" # string
whatd u do ahaha
so you was basicly trying to do:
if 50640 == "50640" ...:`
# number // string (text)
this would never be true
Hmmm ok ok that made sense
Can you also look at my other function right here too?
for idx in range(num_rows):
plant_id = cell(idx, 'plant_id')
technology = cell(idx, 'technology')
net_summer_capacity = cell(idx, 'net_summer_capacity')
if net_summer_capacity == "" or float(net_summer_capacity) <= 5:
continue
if technology.lower() == "conventional hydroelectric":
powerful_hydro_electric_plants.append()
powerful_hydro_electric_plants = sorted(list(set(powerful_hydro_electric_plants)))
powerful_hydro_electric_plants ```
Idk what to put inside my powerful_hydro_electric_plants.append()
@woeful mirage
could you show the assigment?
Oh nvm gui i figured it out myself I know I what I did wrong haha
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.