Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pd.datetimeindex

df = pd.DataFrame({"Price":[120, 240, 350, 460, 500], "Date":["2020-02-01", "2020-08-12", "2021-04-10", "2021-10-20", "2022-03-19"]})
datetime_series = pd.to_datetime(df["Date"])
datetime_index = pd.DatetimeIndex(datetime_series.values)
new_df=df.set_index(datetime_index)
new_df.drop('Date',axis=1,inplace=True)
print(new_df)

#output
#            Price
#2020-02-01    120
#2020-08-12    240
#2021-04-10    350
#2021-10-20    460
#2022-03-19    500
Comment

PREVIOUS NEXT
Code Example
Python :: python typecast 
Python :: initialize np array 
Python :: python milisegundos 
Python :: divide all values in array python 
Python :: how to add labels on bar of barchart seaborn 
Python :: python telegram bot login 
Python :: how to get the most common number in python 
Python :: python 3 tkinter treeview example 
Python :: mean python 
Python :: update all pip packages 
Python :: pandas count show one column 
Python :: python multiple conditions in dataframe column values 
Python :: Delete file in python Using the shutil module 
Python :: copy dataframe columns names 
Python :: cannot reshape array of size 2137674 into shape (1024,512,3,3) 
Python :: python for dummies 
Python :: python panda count excel sheet 
Python :: edit models in django admin 
Python :: check if item exists in list python 
Python :: how to convert response to beautifulsoup object 
Python :: login url 
Python :: python t test 
Python :: string to list python 
Python :: python -c 
Python :: Customize color stacked bar chart matplotlib 
Python :: django jazzmin pypi 
Python :: python tuple get index of element 
Python :: draw picture in python libraries 
Python :: pyttsx3 
Python :: python common elements in two arrays 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =