Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to set index pandas

# assignment copy
df = df.set_index('month')

# or inplace
df.set_index('month', inplace=True)

#      year   sale  month            month  year   sale
#  0   2012   55    1                1      2012   55
#  1   2014   40    4       =>       4      2014   40
#  2   2013   84    7                7      2013   84
#  3   2014   31    10               10     2014   31
Comment

how to change index in dataframe python

index = [1,2]
df.index = index
Comment

change index to dataframe pandas

#cree un indice par defaut sur la base de donnee
df.reset_index()
Comment

dataframe change index

>>> df.set_index('month')
       year  sale
month
1      2012    55
4      2014    40
7      2013    84
10     2014    31
Comment

series change index pandas

x.index = index_values
Comment

PREVIOUS NEXT
Code Example
Python :: custom django user model 
Python :: python threading 
Python :: coding planets 
Python :: how to use dictionaries in python 
Python :: python longest list in list 
Python :: upload to test pypi 
Python :: django url static 
Python :: django datepicker 
Python :: generate random integers 
Python :: display keys in a dictionary python 
Python :: sqlalchemy_database_uri 
Python :: generate all combinatinosrs of a list pyton 
Python :: python icon on task bar 
Python :: area of trapezium 
Python :: how to install python pyautogui 
Python :: python script in excel 
Python :: python print last 3 
Python :: simple jwt 
Python :: python memory usage 
Python :: how to convert csv into list 
Python :: hash() python 
Python :: how to install docx in python 
Python :: depth first search python 
Python :: tkinter dialog box 
Python :: import discord python 
Python :: convert list to set python 
Python :: add new row to dataframe pandas 
Python :: python modulus 
Python :: unique value python 
Python :: How do I iterate over a subfolder in Python 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =