Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将具有不同时区的datetime转换为特定日期中的日期_Python_Pandas - Fatal编程技术网

Python 将具有不同时区的datetime转换为特定日期中的日期

Python 将具有不同时区的datetime转换为特定日期中的日期,python,pandas,Python,Pandas,属性来存储最近赢得的交易,它以非常奇怪的格式存储信息。数据是具有不同时区的日期时间格式 我收到以下错误: 2018-11-16 11:32:51.285000+01:00 2019-02-28 17:13:49.492000+01:00 2018-08-29 09:50:51+02:00 2019-11-16 2019-02-28 2018-08-29 “如果tzaware,则这些值表示unix时间戳,因此我们”和“ValueError:数组必须是同一时区” 当我尝试以

属性来存储最近赢得的交易,它以非常奇怪的格式存储信息。数据是具有不同时区的日期时间格式

我收到以下错误:

2018-11-16 11:32:51.285000+01:00    
2019-02-28 17:13:49.492000+01:00    
2018-08-29 09:50:51+02:00   
2019-11-16
2019-02-28
2018-08-29
“如果tzaware,则这些值表示unix时间戳,因此我们”和“ValueError:数组必须是同一时区”

当我尝试以下命令之一时:

pd.to\u datetime(df1['properties\uu recent\u deal\u close\u date\u value']

我想转换如下数据:

2018-11-16 11:32:51.285000+01:00    
2019-02-28 17:13:49.492000+01:00    
2018-08-29 09:50:51+02:00   
2019-11-16
2019-02-28
2018-08-29
对此:

2018-11-16 11:32:51.285000+01:00    
2019-02-28 17:13:49.492000+01:00    
2018-08-29 09:50:51+02:00   
2019-11-16
2019-02-28
2018-08-29
使用:

输出

Date: 2018-11-16
Date: 2019-02-28
Date: 2018-08-29

谢谢我只需要弄清楚如何遍历所有行。@MatijaŽiberna
对于索引,df.iterrows()中的行:
对于索引,df1中的行。iterrows():row['properties\uu recent\u deal\u close\u date\uu value']=dparser.parse(row,fuzzy=True)。date()
这是我尝试过的。我收到了以下错误:
TypeError:Parser必须是字符串或字符流,而不是序列
Try:
对于索引,df1.iterrows()中的行:print(dparser.parse(row['properties\uu recent\u deal\u close\u date\uu value'],fuzzy=True)。date()
这是另一个错误,只需将其转换为字符串:
对于索引,df1.iterrows()中的行:print(dparser.parse(str(行['properties\uu recent\u deal\u close\u date\uu value')),fuzzy=True.date())