#๐ Help
25 messages ยท Page 1 of 1 (latest)
@wooden zodiac
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.
you can declare a variable and assign it the value you get from your keyboard
x = int(input("Please insert a number: "))
what exactly are you stuck on?
you can post the code either by ```py <your code>```
or !paste
but i'm not gonna open csv files
!paste
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
not really but i might be able to figure it out
send the code
paste it here i mean
Hey @wooden zodiac!
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.
do your prints actually print anything?
if user_input == "1":
print(rdf1)
if user_input == "2":
print(rdf2)
if user_input == "3":
print(rdf3)
also you are trying to use .iloc on file instead of the panada's dataframe
you have the iloc documentation here:
https://pandas.pydata.org/docs/reference/api/pandas.Series.iloc.html#pandas.Series.iloc
did your teacher sugest to use pandas? it seems like a big ask for someone who is just learning python
give me a ss of the data i will look over it
kinda hard to understand what you are working with
i belive you can do something like this
user_region_input = input(f'Enter Region period {options2}: ')
user_year_input = input(f"Enter Year: {options}: ")
if user_region_input == 1 and user_year_input == 1:
# 1:19 should select all the colums with countries in asia
# 1:120 should select the number of rows coresponding to that period
file.iloc(1:120, 1:19)
# you might need to set the last number as 19 + 1 / 120 + 1(i'm pretty sure the last row/column number will not be included)
if you want to do something more dynamic this should also work
# Define the ranges for countries and years in dictionaries
countries = {
1: (1, 19),
2: (20, 29)
}
years = {
1: (1, 120),
2: (121, 240)
}
user_year_input = int(input("Enter the year: "))
user_country_input = int(input("Enter the country: "))
if user_year_input in years:
start_row, end_row = years[user_year_input]
if user_country_input in countries:
start_column, end_column = countries[user_country_input]
# Use the variables in iloc function
sliced_data = file.iloc[start_row:end_row, start_column:end_column]
for points 5 and 6 you should know what a class is:
i suggest going to https://www.geeksforgeeks.org/python-classes-and-objects/
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.