How to set dataframe based on Index Name Column name

0 votes

Jun 29, 2020 in Python by Gaurav
• 120 points

retagged Jun 29, 2020 by Gitika 1,123 views

1 answer to this question.

0 votes

Hi@Gaurav,

You can use set_index function in pandas. It allows you to set an index according to your requirement. You can use this below code.

import pandas as pd
df= pd.DataFrame({"Day":[1,2,3,4], "Visitors":[200, 100,230,300], "Bounce_Rate":[20,45,60,10]}) 
df.set_index("Day", inplace= True)
Day visitors  Bounce_Rate
1 200 20
2 100 45
3 230 60
4 300 10
answered Jun 29, 2020 by MD
• 95,460 points

Related Questions In Python

0 votes
1 answer

How to set value for particular cell in pandas DataFrame using index?

Why df.xs('C')['x']=10 does not work: df.xs('C') by default, returns a new ...READ MORE

answered Jan 5, 2021 in Python by Gitika
• 65,770 points
3,507 views
0 votes
0 answers

how to merge two data frames based on particular column in pandas python?

I want to  merge two data frames: df1 company,standard tata,A1 cts,A2 dell,A3 df2 company,return tata,71 dell,78 cts,27 hcl,23 I ...READ MORE

May 26, 2022 in Python by Kichu
• 19,040 points
509 views
0 votes
1 answer

How to find index from raw and column in python?

You probably want to use np.ravel_multi_index: import numpy as ...READ MORE

answered Sep 12, 2018 in Python by Priyaj
• 58,020 points
987 views
0 votes
1 answer

How to find index from raw and column in python?

You probably want to use np.ravel_multi_index: import numpy as ...READ MORE

answered Sep 24, 2018 in Python by Priyaj
• 58,020 points
1,306 views
0 votes
1 answer

How to append dataframe without index?

You have to use the ignore_index option. ...READ MORE

answered Apr 1, 2019 in Python by Robert
15,344 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,465 views
0 votes
1 answer

How to set colume as index in Pandas DataFrame?

Hi@akhtar, You can use set_index function in pandas. ...READ MORE

answered Jun 23, 2020 in Python by MD
• 95,460 points
744 views
0 votes
1 answer

How to delete column from pandas DataFrame?

Hi@akhtar, You can use the del command in ...READ MORE

answered Jun 24, 2020 in Python by MD
• 95,460 points
1,160 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP