Search Results
|
Post |
Author |
Forum |
Replies |
Views |
Posted
[asc]
|
|
|
Thread: add the suffix to the next line
Post: RE: add the suffix to the next line
Thanks, already tried and it would have been too nice if it worked **cry** .... the \n when used in the add_ suffix or add_prefix is treated like a text within the ' ' and not as a command like in ... |
|
Paulman |
General Coding Help |
2 |
1,409 |
Dec-05-2021, 10:48 AM |
|
|
Thread: add the suffix to the next line
Post: add the suffix to the next line
Hi,
Does anybody know the shortest command to add a suffix to the header of several columns below the header and not on the same line?
I have the dataframe below:
Type Price1 Price2 ... |
|
Paulman |
General Coding Help |
2 |
1,409 |
Dec-04-2021, 05:55 PM |
|
|
Thread: Use of groupby in a function with Pandas
Post: Use of groupby in a function with Pandas
Hello,
I'm totally stuck with a task on using groupby in a dataframe.
I have the following df in a csv file 'athletes.csv:
,forename,surname,gender,age,100m,200m,400m,800m,1500m
0,Migdalia,Parrish,... |
|
Paulman |
General Coding Help |
0 |
964 |
Dec-03-2021, 04:56 PM |
|
|
Thread: for loop in dataframe in pandas
Post: RE: for loop in dataframe in pandas
(Dec-01-2021, 07:50 PM)bowlofred Wrote: You're creating a (new, empty) collection inside the loop. So each time through you throw away the old one.
Create the collection outside the loop.
append t... |
|
Paulman |
General Coding Help |
7 |
2,773 |
Dec-01-2021, 10:55 PM |
|
|
Thread: for loop in dataframe in pandas
Post: RE: for loop in dataframe in pandas
(Dec-01-2021, 05:28 PM)bowlofred Wrote: Each time through the loop you create (and overwrite if already created) athletes_data_dict. You're not storing the one for each age anywhere. You need a co... |
|
Paulman |
General Coding Help |
7 |
2,773 |
Dec-01-2021, 06:25 PM |
|
|
Thread: for loop in dataframe in pandas
Post: RE: for loop in dataframe in pandas
(Dec-01-2021, 04:21 PM)DPaul Wrote: It seems that in your "athletes_data_dict" you are using fixed key names (forename,surname,time),
over and over again. Keys should be unique in a dictionary.
Pau... |
|
Paulman |
General Coding Help |
7 |
2,773 |
Dec-01-2021, 04:39 PM |
|
|
Thread: for loop in dataframe in pandas
Post: for loop in dataframe in pandas
Hello,
I have a problem with a "for loop" using a dataframe in pandas, hope somebody can help with that.
I have the following dataframe in a csv file:
,forename,surname,gender,age,100m,200m,400m,80... |
|
Paulman |
General Coding Help |
7 |
2,773 |
Dec-01-2021, 02:35 PM |
|
|
Thread: function for generating graph bar from list
Post: RE: function for generating graph bar from list
OK found the solution for the 3b:
def show_ducks_weights(duck_list):
x = [d["name"] for d in duck_list]
y = [d["weight"] for d in duck_list]
fig1b, ax = plt.subplots(figsize=(12, 8), dpi=... |
|
Paulman |
Homework |
4 |
1,801 |
Nov-10-2021, 03:33 PM |
|
|
Thread: function for generating graph bar from list
Post: RE: function for generating graph bar from list
OK, thanks. From my understanding of your comment I should have assigned the names and weights to x and y as below, but now the bar chart practically is empty, why?
import matplotlib.pyplot as plt
im... |
|
Paulman |
Homework |
4 |
1,801 |
Nov-10-2021, 01:56 PM |
|
|
Thread: function for generating graph bar from list
Post: function for generating graph bar from list
I had to generate a bar chart from a list. I solved it in the simple way with no problems (Task 3a in the code below).
After that I wanted to write the code in the form of function (Task 3b).
The c... |
|
Paulman |
Homework |
4 |
1,801 |
Nov-10-2021, 01:08 PM |
|
|
Thread: function for extracting data from lists
Post: RE: function for extracting data from lists
Wow... OK now I understand!! Many thanks, I was becoming crazy complicating thing and looping my brain instead of coding, now it finally works as expected (below the correct code). Many thanks again, ... |
|
Paulman |
Homework |
9 |
2,808 |
Nov-09-2021, 04:00 PM |
|
|
Thread: function for extracting data from lists
Post: RE: function for extracting data from lists
Thanks for the help, I'm nearly there.... hopefully: now I have the code below that works and gives the last value of the list as you said. Then I tried to use "append" in order to have all the values... |
|
Paulman |
Homework |
9 |
2,808 |
Nov-09-2021, 01:16 PM |
|
|
Thread: function for extracting data from lists
Post: RE: function for extracting data from lists
OK thanks, then my understanding from your comment is the below, but didn't work as well:
def main(list_1):
return main
list_1 = [
{'name': 'Jerome', 'weight': 3.38, 'wingspan': 49.96, 'len... |
|
Paulman |
Homework |
9 |
2,808 |
Nov-09-2021, 10:12 AM |
|
|
Thread: function for extracting data from lists
Post: RE: function for extracting data from lists
OK thanks, then I did the following code:
def main(list_1):
return main
list_1 = [
{'name': 'Jerome', 'weight': 3.38, 'wingspan': 49.96, 'length': 19.75},
{'name': 'Ibraheem', 'weight': ... |
|
Paulman |
Homework |
9 |
2,808 |
Nov-08-2021, 11:50 PM |
|
|
Thread: function for extracting data from lists
Post: function for extracting data from lists
Hi,
I'm struggling with this problem:
create a function named get_data, that takes two arguments, Data and Key.
- Data is the list of dictionaries in list_1
- Key are the data that I need to extrac... |
|
Paulman |
Homework |
9 |
2,808 |
Nov-08-2021, 12:46 AM |
|
|
Thread: Use of function/return
Post: RE: Use of function/return
OK many thanks, that's incredibly short, very nice.
In the meantime I managed to do the below, trying to follow your suggestions, to me it looks working fine, much more complicated than your for sure... |
|
Paulman |
Homework |
6 |
2,372 |
Oct-24-2021, 11:07 PM |
|
|
Thread: Use of function/return
Post: RE: Use of function/return
Do you mean the below?
def add_up_the_odds(numbers):
add_up_the_odds = []
for number in range(1,len(numbers)):
if number % 2 == 1:
add_up_the_odds.append(number)
ret... |
|
Paulman |
Homework |
6 |
2,372 |
Oct-24-2021, 09:40 PM |
|
|
Thread: Use of function/return
Post: RE: Use of function/return
I tried with this then:
def add_up_the_odds(numbers):
odds = []
for number in range(1,len(numbers)):
if number % 2 == 1:
odds.append(number)
return odds
numbers = [1,5,3,2... |
|
Paulman |
Homework |
6 |
2,372 |
Oct-24-2021, 09:29 PM |
|
|
Thread: Use of function/return
Post: Use of function/return
Hello all,
I had the task to code the following:
Take a list of integers and returns the value of these numbers added up, but only if they are odd.
- Example input: [1,5,3,2]
- Output: 9
I did the... |
|
Paulman |
Homework |
6 |
2,372 |
Oct-24-2021, 12:56 PM |
|
|
Thread: print on a single line with start/end brackets and commas
Post: RE: print on a single line with start/end brackets...
That's great, many thanks!! |
|
Paulman |
Homework |
2 |
1,864 |
Oct-23-2021, 10:00 AM |