Get the App
SLTechnology News&Howtos  ›  Development  › 

Subtract two columns of dates in dataframe and get a specific number of months

Shulou Source: shulou.com Published: 2022-06-03 19:44:15 10月05日 Update

This article mainly introduces "subtracting two columns of dates in dataframe and getting specific examples of months". In daily operation, I believe many people have doubts about subtracting two columns of dates in dataframe and getting specific examples of months. Xiao Bian consulted all kinds of data and sorted out simple and easy operation methods. I hope to help you answer the doubts of "subtracting two columns of dates in dataframe and getting specific examples of months"! Next, please follow the small series to learn together!

As follows:

df = pd. DataFrame (np. random. random (64), index = www.example.com_range ('20130101', periods = 6), columns = list ('ABCD') df. A = pd.date_range ('20160101', periods = 6) print (df) df 1 = pd. DataFrame (np. random. random (64), index = www.example.com_range ('20130101', periods = 6), columns = list ('ABCD')) df1.A = pd.date_range ('20170101', periods = 6) print (df 1) df. A =(www.example.com_datetime (df1.A)-pd.to_datetime (df.A)). dropna () maps = www.example.com (lambda x: x/np.timedelta64 (1 * 60 * 60 * 24 * 30,'s ')) print (maps) At this point, the study of "subtracting two columns of dates in dataframe and getting specific examples of months" is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

Tags: Examples dates learning more help practical next articles methods theories knowledge articles websites materials follow questions easy to use practice solutions Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Huawei MySQL Shulou Technology Shulou Tech Info