Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I have this sample of a data frame showing population over the years.
I want to remove the row labels 'Country Code' altogether and have the next column, 'Country Name', as the row labels instead. How can I do this?
Let me know if you need more information or anything is not clear.
df = df.set_index('Country Name')
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 days ago.
Improve this question
I have created this scatter graph but want to get the p-value for it: enter image description here
I tried looking at other answers but they all seemed overcomplicated.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I want to select the rows where the revenue is NaN. So, row 7 and row 43 should be selected. I tried the code (In[117]) shown in the screenshot but it doesn't work for me.
You can use isna
NaN_table[NaN_table.Revenue.isna()]
Just use isnull:
NaN_table[NaN_table['Revenue'].isnull()]
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
i want to cut all the columns of Data Frame. When I print the result it show good result, but when I want to assign those values in new data frame it returns NaNs.example of code
You need to paste your code here for understanding proper solution of problem.
you can try to add one line of code:
slc=slc.reset_index(drop=True)
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I have a csv file of stock prices for each trading day for 9 years. how do i get the last trading day of each month and the respective prices?
I have tried grouping by months followed by the largest day but it doesn't seem to be working. Any guidance or suggestions pls
file:///var/folders/76/qqn_44f945564bdvv8dw_0jc0000gn/T/com.apple.Safari/WebKitDropDestination-wOBqM5Fs/Screenshot%202019-08-19%20at%205.03.22%20PM.png
import pandas as pd
data=pd.read_csv('csv_file')
data
type(data.index)
data.set_index('date',inplace=True)
Apologies, its my first time using this so i don't really know how to post the code. But this is the code i have so far. The url is the result of the csv data.
You can use
df.groupby([pd.Grouper(key = 'column_containing date', freq = 'M')])['column_containing date'].last()
If your date data is part of the index you can use
df.groupby(df.index.strftime('%Y-%m')).tail(1)
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
List 1:
['buying','maint']
List 2:
[['med', 'vhigh', 'low', 'high'],['med', 'small', 'big']]
Expected_output:
[['buying_med', 'buying_vhigh','buying_low','buying_high'],['maint_med','maint_small','maint_big']]
Please let mw know on how to do this in python 3.
This sounds like a homework problem so I will only give a suggestion to push you in the right direction. Start with trying to implement a solution with 2 for loops. If you want to improve your answer, take a look at list comprehensions.