CSV中日期的最大和最小功能-获得不同的结果

时间:2018-08-07 10:15:12

标签: python date

在将max()和min()函数应用于日期时,我没有得到期望的结果。

注意:我已经通过pandas导入了文件。下面是数据。

sample.csv --->

Trans_no    id  last_Transaction    amount
1   48280   8/15/2016   0
2   281301  6/11/2017   0
3   369080  5/17/2017   0
4   1722942 1/30/2018   60
5   2142311 1/31/2018   20
6   977001  1/31/2018   125
7   1004805 1/13/2018   100
8   401750  3/18/2017   0
9   1004805 2/17/2018   40
10  1722942 2/28/2018   56
11  401750  3/18/2017   0
12  2142311 2/28/2018   20
13  48280   8/15/2016   0
14  281301  6/11/2017   0
15  48280   8/15/2016   0
16  369080  5/17/2017   0
17  281301  6/11/2017   0
18  977001  2/21/2018   150
19  369080  3/8/2018    10
20  977001  3/21/2018   150
21  401750  3/18/2017   0
22  2142311 3/22/2018   22
23  1722942 3/28/2018   56
24  1004805 3/19/2018   90
25  48280   8/15/2016   0
26  281301  6/11/2017   0
27  2142311 4/28/2018   40
28  369080  3/8/2018    0
29  1722942 4/18/2018   26
30  977001  3/21/2018   0
31  1004805 3/19/2018   0
32  401750  3/18/2017   0
33  48280   8/15/2016   0
34  281301  6/11/2017   0
35  1722942 4/18/2018   0
36  369080  3/8/2018    0
37  2142311 5/28/2018   32
38  1004805 3/19/2018   0
39  401750  3/18/2017   0

当前代码:

import pandas as pd
import warnings
import datetime as dt

warnings.filterwarnings('ignore')
df = pd.read_csv("sample.csv")
#print(df.head())
df1=df

print(df1['last_Transaction'].min())

print(df1['last_Transaction'].max())

Output:


1/13/2018
8/15/2016

为什么最晚日期是2018年1月13日?和最长日期为2016年8月15日?

0 个答案:

没有答案