How to calculate the difference between two date with Pandas in case timedelta is not supported?

# ``` loan_data['mths_since_earliest_cr_line_date']=round(pd.to_numeric((pd.to_datetime('2017-12-01')-loan_data['earliest_cr_line_date'])/pd.Timedelta(1,unit='M')))

``` --------------------------------------------------------------------------- ``` ValueError Traceback (most recent call last) Cell In[99], line 1 ----> 1 loan_data['mths_since_earliest_cr_line_date']=round(pd.to_numeric((pd.to_datetime('2017-12-01')-loan_data['earliest_cr_line_date'])/pd.Timedelta(1,unit='M'))) File timedeltas.pyx:1821, in pandas._libs.tslibs.timedeltas.Timedelta.__new__() File timedeltas.pyx:827, in pandas._libs.tslibs.timedeltas.disallow_ambiguous_unit() ValueError: Units 'M', 'Y', and 'y' are no longer supported, as they do not represent unambiguous timedelta values durations." ``` please help me and thank you soooo much!!! '2017-12-01'is the enddate,'2017-12-01')-loan_data['earliest_cr_line_date'] is the startdate,i need to calculate the month between two dates.my logic is :calculate the difference between two dates with days and then covert days to month using pd.timedelta method.

To calculate the phase change energy from bcc to fcc using LAMMPS, you can use the lattice orientation relationship method. This method involves creating a bcc and fcc crystal in LAMMPS, aligning their lattice orientations, and then calculating the energy difference between the two structures. Here is an example LAMMPS input script that demonstrates this method: ``` # Create bcc crystal units metal atom_style atomic lattice bcc 2.855 region box block 0 10 0 10 0 10 create_box 1 box create_atoms 1 box mass 1 55.85 # Relax bcc structure pair_style eam pair_coeff * * Fe_u3.eam neighbor 2.0 bin neigh_modify every 20 delay 0 check no fix 1 all box/relax iso 0.0 vmax 0.001 thermo 10 thermo_style custom step pe lx ly lz press pxx pyy pzz minimize 1e-8 1e-8 1000 10000 # Create fcc crystal clear units metal atom_style atomic lattice fcc 3.615 region box block 0 10 0 10 0 10 create_box 1 box create_atoms 1 box mass 1 55.85 # Align lattice orientations clear units metal atom_style atomic lattice fcc 3.615 orient x 1 0 0 orient y 0 1 0 orient z 0 0 1 region box block 0 10 0 10 0 10 create_box 1 box create_atoms 1 box mass 1 55.85 group fcc type 1 group bcc type 2 fix 1 fcc setforce 0.0 0.0 0.0 fix 2 bcc setforce 0.0 0.0 0.0 minimize 1e-8 1e-8 1000 10000 variable dx equal lx/10.0 variable dy equal ly/10.0 variable dz equal lz/10.0 displace_atoms bcc move ${dx} 0.0 0.0 # Calculate energy difference compute bccpe bcc pe compute fccpe fcc pe variable dE equal c_fccpe-c_bccpe print "Energy difference: ${dE} eV/atom" ``` This script first creates a bcc crystal and relaxes its structure using the EAM potential for iron. It then creates an fcc crystal and aligns its lattice orientation with the bcc crystal. The two structures are then minimized to their equilibrium positions. Finally, the energy difference between the fcc and bcc structures is calculated using the compute command in LAMMPS. Note that you will need to replace the EAM potential file `Fe_u3.eam` with the appropriate potential for your system. I hope this helps!
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值