Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 months ago.
Improve this question
Is there any nice build in function in pandas which can convert values in DataFrame to percent (by rows, by columns or any more complex combination with use of levels)?
Im not sure that is what you mean, but if you want to know the percentage value within the columns you can do it like this:
for col in df:
df[col] = (df[col]/df[col].sum()) * 100
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed yesterday.
Improve this question
there is one dataframe with columns A and B, each value in A has many values in B,
i want to perform few steps on rows for each of the value in A.
could you help to do it in spark
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I'm trying to count the columns that have the same name. I need a formula to apply it to all data.
For example, I am trying to count the amount of cloumns with ID=11 and write them in row "N".
Is there a simple formula for this?
Try using COUNTIF:
=COUNTIF(A3:A25, 11)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I had to fill the null values in age column. I did some analysis and formed a code to do this. i ran the code but still there is no change in the data.
for index,i in df[df['Age'].isna()==True].iterrows():
pc = i['Pclass']
ss = i['SibSp']
i['Age'] = df[(df['Pclass']==pc ) & (df['SibSp']==ss)]['Age'].mean()
I assume you are trying to fill the missing Age values with mean value of those age which are available Age. If that is the case, simply do this.
df['Age'] = df['Age'].fillna(df['Age'].mean(), axis=0)
or, as #JonClements suggested below, use inplace
df['Age'].fillna(df['Age'].mean(), inplace=True)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I am unable to get sentiment for all the rows in the dataframe. Able to see sentiment for only one row.
text = doc.text[0]
This statement only brings 1st row. Hence, you see only 1st row in your answerset.
For getting sentiments for all rows, run a loop:
for index, row in doc.iterrows():
text = row[0]
obj = TextBlob(text)
sentiment = obj.sentiment.polarity
print(sentiment)
Let me know if it works.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Dataset:
Need output like below in using dataframe pandas. I would like to group by PRCP based on the PRCP range and aggregate the count. Please advise
import pandas as pd
df = pd.DataFrame({'CLDATE':['1/1/16','1/10/16','1/11/16','11/12/16','11/13/16','11/14/16','11/15/16','11/16/16'],
'count':[64396,49877,41603,41124,45839,45846,52719,59626],'PRCP':[0,1.8,0,0,0,0,0,0.24]})
df['precipate_Range']=pd.cut(df['PRCP'],[0,1,2,3],right=False,labels=['0-1','1-2','2-3'])
df.groupby('precipate_Range')['count'].agg({'Sum':'sum'}).reset_index()
Output:
precipate_Range Sum
0 0-1 351153.0
1 1-2 49877.0
2 2-3 NaN