Subtract two columns of dates in dataframe and get a specific example of the number of months
As shown below:
df = ((6,4), index=pd.date_range('20130101', periods=6), columns=list('ABCD')) = pd.date_range('20160101', periods=6) print (df) df1 = ((6,4), index=pd.date_range('20130101', periods=6), columns=list('ABCD')) = pd.date_range('20170101', periods=6) print (df1) = (pd.to_datetime() - pd.to_datetime()).dropna() maps = (lambda x: x/np.timedelta64(1*60*60*24*30, 's')) print (maps)
The above example of subtracting the dates of two columns in dataframe and obtaining specific months is all the content I share with you. I hope you can give you a reference and I hope you can support me more.
Related Articles
Analysis of usage of() in Python
This article mainly introduces the analysis of the usage of () in Python. The example code is introduced in this article in detail, which has certain reference learning value for everyone's study or work. Friends who need it, please learn with the editor below.2023-03-03Advanced usage techniques for PyQt5 signals and slots in python GUI library graphical interface development Detailed usage methods and examples of decorator signals and slots
This article mainly introduces the advanced usage skills of PyQt5 signals and slots in the python GUI library graphical interface development. Detailed usage methods and examples of decorator signals and slots. Friends who need it can refer to it.2020-03-03Tutorial on graphic and text for building a python development environment under Win7 (install Python, pip, interpreter)
This article mainly shares with you the graphic tutorial on building a python development environment under Win7. This article mainly introduces the detailed steps for installing Python, pip, and interpreter. Interested friends can refer to it.2016-05-05python OpenCV realizes answer sheet recognition and paper judgment
This article mainly introduces the python OpenCV answer sheet recognition and judgment papers in detail. The sample code in the article is introduced in detail and has certain reference value. Interested friends can refer to it.2021-06-06Django one-to-many model and how to implement it in the front-end detailed explanation
This article mainly introduces the one-to-many model of django and how to implement it in the front-end. The article introduces the example code in detail, which has certain reference learning value for everyone's learning or work. Friends who need it can refer to it.2019-07-07Python implements the method of calculating network segments based on IP address and subnet mask
This article mainly introduces the method of Python to calculate network segments based on IP address and subnet mask. It involves Python's string operation skills based on Linux platform. It has certain reference value. Friends who need it can refer to it.2015-07-07pytorch tutorial network construction process notes
This article mainly introduces the network construction process in the pytorch tutorial. The article includes detailed sample code flow. Friends in need can refer to it. I hope it can be helpful.2021-09-09Use Python to automatically clean duplicate files in your computer, with only 10 lines of code (automatic script)
This article mainly introduces the use of Python to automatically clean duplicate files in the computer. There are only 10 lines of code. This article introduces you very detailedly and has certain reference value for your study or work. Friends who need it can refer to it.2021-01-01Interpreting the use of degrees() method in Python
This article mainly introduces the use of the degree() method in Python, which is the basic knowledge in the introduction to Python. Friends who need it can refer to it.2015-05-05Detailed explanation of the use and instructions of python ChainMap
This article mainly introduces the detailed explanation of the use and explanation of python ChainMap. The example code is introduced in this article in detail, which has certain reference learning value for everyone's study or work. Friends who need it, please learn with the editor below.2019-06-06