Pandas how to display pivoted values UNDER columns [duplicate] - pandas

This question already has answers here:
How can I pivot a dataframe?
(5 answers)
How do I change order/grouping/level of pandas MultiIndex columns?
(3 answers)
Closed 3 years ago.
I need the below but with USD and EU under each of Bronze, Gold and Silver. How?
Edit - My question is different because I want the columns ABOVE the values.

Related

Create a new column with value 1/0 based on other column value in pandas [duplicate]

This question already has answers here:
Adding a new pandas column with mapped value from a dictionary [duplicate]
(1 answer)
Pandas conditional creation of a series/dataframe column
(13 answers)
Mapping values in place (for example with Gender) from string to int in Pandas dataframe [duplicate]
(3 answers)
Closed 9 hours ago.
I want to create a column with values 1 for female, 0 for male based on the gender column in Pandas.
Is using a for loop efficient?

How do create lists of items for every unique ID in a Pandas DataFrame? [duplicate]

This question already has answers here:
How to get unique values from multiple columns in a pandas groupby
(3 answers)
Python pandas unique value ignoring NaN
(4 answers)
Closed 1 year ago.
Imagine I have a table that looks like this.
original table
How do I convert it into this?
converted table
Attached sample data. Thanks.

How to use nlasgest in pandas? [duplicate]

This question already has answers here:
Pandas max value index
(3 answers)
Closed 2 years ago.
I'm looking for the highest row of a dataframa, actually the idea is to pick the highest value and the index. I'm trying to use this code:
data_q11.nlargest(144,['1980','2010'])
where data_q11 is the dataframe,144 the number os rows in this df and range of columns.
Although the result is returning a empty list of 0 rows and x 31 columns.
There is a function in Pandas for the index of the maximum value:
data_q11['col'].idxmax(axis=1)

what does data[:,0] or data[:,1] mean in pandas [duplicate]

This question already has answers here:
Extracting specific columns in numpy array
(10 answers)
Closed 2 years ago.
I am new to pandas and I saw some pandas code which says
plt.scatter(data[:,0],data[:,1])
I want to know what does data[:,0] and data[:,1] means?
Thas mean:
data[:,0] - > All the first column of the dataset
data[:,1] -> All the second colum of the dataset

pandas dataframe to list(just care about data) [duplicate]

This question already has answers here:
Pandas DataFrame to List of Lists
(14 answers)
Closed 5 years ago.
I have a dataframe like this:
how can i get the list like:
[[2017-08-01,1.18263,1.18266,1.18109,1.18113],
......,
[2017-08-18,1.18263,1.18266,1.18109,1.18113]]
DataFrame.values returns the data as a numpy array, from there you can go to a list by adding tolist()