- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一个脚本可以收集数据。我遇到了 TypeError: Timestamp subtraction must have the same timezones or no timezones
错误。我查看了有关此错误的其他帖子,但找不到适合我的解决方案。
我怎样才能绕过这个错误。收集数据后,我不会对其进行操作,我不太明白为什么我不能将此 dataframe
保存到 excel 文档中。谁能提供帮助?
import pandas as pd
import numpy as np
import os
import datetime
import pvlib
from pvlib.forecast import GFS, NAM
#directories and filepaths
barnwell_dir = r'D:\Saurabh\Production Forecasting\Machine Learning\Sites\Barnwell'
barnwell_training = r'8760_barnwell.xlsx'
#constants
writer = pd.ExcelWriter('test' + '_PythonExport.xlsx', engine='xlsxwriter')
time_zone = 'Etc/GMT+5'
barnwell_list = [r'8760_barnwell.xlsx', 33.2376, -81.3510]
def get_gfs_processed_data1():
start = pd.Timestamp(datetime.date.today(), tz=time_zone) #used for testing last week
end = start + pd.Timedelta(days=6)
gfs = GFS(resolution='quarter')
#get processed data for lat/long point
forecasted_data = gfs.get_processed_data(barnwell_list[1], barnwell_list[2], start, end)
forecasted_data.to_excel(writer, sheet_name='Sheet1')
get_gfs_processed_data1()
最佳答案
当我运行您的示例代码时,我在堆栈跟踪的末尾收到来自 XlsxWriter 的以下警告:
"Excel doesn't support timezones in datetimes. "
TypeError: Excel doesn't support timezones in datetimes.
Set the tzinfo in the datetime/time object to None or use the
'remove_timezone' Workbook() option
我认为这是不言自明的。要从时间戳中去除时区,请按照建议传递 remove_timezone
选项:
writer = pd.ExcelWriter('test' + '_PythonExport.xlsx',
engine='xlsxwriter',
options={'remove_timezone': True})
当我进行此更改时,示例会运行并生成一个 xlsx 文件。请注意,remove_timezone
选项需要 XlsxWriter >= 0.9.5。
关于python - 类型错误 : Timestamp subtraction,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44708735/
标题基本上说明了一切。 我主要对更新案例感兴趣。假设我们正在尝试更新具有时间戳记字段的记录,并且我们希望将该字段设置为记录更新的时间戳记。有没有办法做到这一点? 最佳答案 经过一些实验,我找到了合适的
我正在学习一门类(class),其中我必须将日期转换为 unix 时间戳。 import pandas as pd df = pd.read_csv('file.csv') print type(df
我在两个不同的数据库中运行了相同的语句:我的本地数据库和 Oracle Live SQL . CREATE TABLE test( timestamp TIMESTAMP DEFAULT SY
我在两个不同的数据库中运行了相同的语句:我的本地数据库和 Oracle Live SQL . CREATE TABLE test( timestamp TIMESTAMP DEFAULT SY
bson.timestamp.Timestamp需要两个参数:time 和 inc。 time 显然是存储在 Timestamp 中的时间值。 什么是公司?它被描述为递增计数器,但它有什么用途呢?它应
2016-08-18 04:52:14 是我从数据库中获取的时间戳,用于跟踪我想从哪里加载更多记录,这些记录小于该时间 这是代码 foreach($explode as $stat){
我想将 erlang:timestamp() 的结果转换为正常的日期类型,公历类型。 普通日期类型表示“日-月-年,时:分:秒”。 ExampleTime = erlang:timeStamp(),
我想将 erlang:timestamp() 的结果转换为正常的日期类型,公历类型。 普通日期类型表示“日-月-年,时:分:秒”。 ExampleTime = erlang:timeStamp(),
我是 Java 新手。我正在使用两个 Timestamp 对象 dateFrom和dateTo 。我想检查是否dateFrom比 dateTo早 45 天。我用这个代码片段来比较这个 if(dateF
在将 panda 对象转换为时间戳时,我遇到了这个奇怪的问题。 Train['date'] 值类似于 01/05/2014,我正在尝试将其转换为 linuxtimestamp。 我的代码: Train
我正在努力让我的代码运行。时间戳似乎有问题。您对我如何更改代码有什么建议吗?我看到之前有人问过这个问题,但没能成功。 这是我在运行代码时遇到的错误:'Timestamp' object has no
我正在尝试运行以下查询: SELECT startDate FROM tests WHERE startDate BETWEEN TIMESTAMP '1555248497'
我正在使用 Athena 查询以 bigInt 格式存储的日期。我想将其转换为友好的时间戳。 我试过了: from_unixtime(timestamp DIV 1000) AS readab
最近进行了一些数据库更改,并且 hibernate 映射出现了一些困惑。 hibernate 映射: ...other fields 成员模型对象: public class Mem
rng = pd.date_range('2016-02-07', periods=7, freq='D') print(rng[0].day) print(rng[0].month) 7 2 我想要
rng = pd.date_range('2016-02-07', periods=7, freq='D') print(rng[0].day) print(rng[0].month) 7 2 我想要
我必须在我的数据库中保存 ServerValue.TIMESTAMP 但它必须是一个字符串。当我键入 String.valueOf(ServerValue.TIMESTAMP); 或 ServerVa
在我的程序中,每个表都有一列 last_modified: last_modified int8 DEFAULT (date_part('epoch'::text, now()::timestamp)
我想将此时间戳对象转换为日期时间此对象是在数据帧上使用 asfreq 后获得的这是最后一个索引 Timestamp('2018-12-01 00:00:00', freq='MS') 想要的输出 2
我有一个包含时间序列传感器数据的大表。大型是指分布在被监控的各个 channel 中的从几千到 10M 的记录。对于某种传感器类型,我需要计算当前读数和上一个读数之间的时间间隔,即找到当前读数之前的最
我是一名优秀的程序员,十分优秀!