我有一个可以收集数据的脚本。我遇到了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 …Run Code Online (Sandbox Code Playgroud) 我正在尝试自学Java,并且正在学习for loops.我正在尝试编写一个简短的程序,它给出了以下输出:
1
1 4
1 4 9
1 4 9 25
我有一种感觉,我在指数部分被绊倒了.我的源代码如下:
public class Forloop {
public static void main(String[] args) {
for (int i = 1; i <= 4; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(int j = Math.pow(j,i));
}
System.out.println();
}
}
Run Code Online (Sandbox Code Playgroud)
}
任何人都可以向我提供任何有关我出错的地方的帮助,也许可以解决它.非常感谢.
我正在尝试combobox使用工作簿中的另一个工作表(称为"其他")填充一系列单元格.
我使用以下作为指导,但它似乎不起作用.有人可以给我建议吗?当我运行时userform,combobox没有任何东西填充.
Private Sub ComboBox1_Change()
Me.ComboBox1.List = Worksheets("Other").range("C2:C11").Value
End Sub
Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个For...Next循环来创建一组Worksheets中的s Workbook.工作表的数量由用户在仪表板中设置,在较早的时候.
有人能指出我正确的方向吗?这是我的代码,到目前为止:
For i = 1 To siteCount
'I know the below won't work, and I also tried site_ & i, but no luck
Set site_i = Sheets.Add(after:=Sheets(Worksheets.Count))
site_i.Name = "Sheet Name"
Next i
Run Code Online (Sandbox Code Playgroud) 我正在编写一个模仿"交易或不交易"游戏的程序.
交易或不交易的背景:http://en.wikipedia.org/wiki/Deal_or_No_Deal
在完成最终产品的过程中,我写了各种课程.但是,我正在尝试测试我的一个课程,并继续获得NullPointerException.
我写了一个名为Box的类,它创建了"box"对象.box对象是玩家选择的实际框.它由true/false值和double boxValue组成.该boolean variable表示无论是开启/关闭(真开放,假封闭式).double boxValue是分配给该框的实际值.
public class Box {
//instance fields
private double boxValue; // the amount of $ in each box
private boolean openClose; // whether or not the box is closed
//Constructor
public Box(double boxValue) {
this.openClose = false;
this.boxValue = boxValue;
if (boxValue < 0) {
throw new IllegalArgumentException("Box value must be greater than 0");
}
}
}
Run Code Online (Sandbox Code Playgroud)
我还编写了另一个名为BoxList的类.这将创建一个Box对象数组,当与我计划编写的其他类结合使用时,它将作为游戏板.主要思想是BoxList中的构造函数通过使用传入double array作为参数创建数组,然后创建一个与传入的double数组长度相同的Box Object数组,并为其分配每个元素的double值parameter array,将Box对象的值array作为对应的元素.
我编写了一个示例main方法来测试,但是当我尝试 …
我正在尝试编写一个处理地震和震级的小程序.
程序运行时,它会要求用户输入一个数字,表示用户想要提交的地震数量.根据响应,程序然后提示用户输入每次地震的幅度.我在下面写了下面的代码但是遇到了麻烦for loop.
显然在for循环中,i <= numberOfEarthquakes不允许程序正确编译.什么是给出i与用户输入的数字相关的条件的简单方法.非常感谢.
(这是我希望写的更大程序的一小部分)
import java.util.*;
public class Earthquakes {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
System.out.print("How many magnitudes will you enter? ");
String numberOfEarthquakes = console.next();
for (int i = 1; i <= numberOfEarthquakes; i++) {
System.out.print("Enter magnitude for earthquake " + i);
String magnitudeOfEarthquake = console.next();
}
}
}
Run Code Online (Sandbox Code Playgroud)