草庐IT

input-datetime

全部标签

python - 分析异常 : u"cannot resolve 'name' given input columns: [ list] in sqlContext in spark

我尝试了一个简单的例子:data=sqlContext.read.format("csv").option("header","true").option("inferSchema","true").load("/databricks-datasets/samples/population-vs-price/data_geo.csv")data.cache()#Cachedataforfasterreusedata=data.dropna()#droprowswithmissingvaluesdata=data.select("2014Populationestimate","2015

python - pd.Timestamp 与 np.datetime64 : are they interchangeable for selected uses?

这个问题的动机是ananswer到questiononimprovingperformance在pandas中与DatetimeIndex进行比较时。该解决方案通过df.index.values将DatetimeIndex转换为numpy数组,并将该数组与np.datetime64对象。这似乎是从此比较中检索bool数组的最有效方法。pandas的一位开发人员对这个问题的反馈是:“这些通常不一样。提供numpy解决方案通常是一种特殊情况,不推荐使用。”我的问题是:对于一部分操作,它们是否可以互换?我很感激DatetimeIndex提供了更多功能,但我只需要基本功能,例如切片和索引。对于

python - SqlAlchemy 不接受 DateTime 列中的 datetime.datetime.now 值

我应该首先提到我通过Flask-SqlAlchemy使用SqlAlchemy。我认为这不会影响问题,但如果有影响,请告诉我。这是我在SqlAlchemy中运行create_all函数时收到的错误消息的相关部分InterfaceError:(InterfaceError)错误绑定(bind)参数4-可能是不支持的类型。u'INSERTINTOpodcasts(feed_url,title,url,last_updated,feed_data)VALUES(?,?,?,?,?)'(u'http://example.com/feed',u'PodcastShowTitle',u'http:/

python - 为什么 Python 3 中的 `input` 抛出 NameError : name. .. 未定义

这个问题在这里已经有了答案:input()error-NameError:name'...'isnotdefined(15个答案)关闭3年前。我有一个字符串变量test,在Python2.x中它工作正常。test=raw_input("enterthetest")printtest但在Python3.x中,我这样做:test=input("enterthetest")printtest输入字符串sdas,我得到一条错误信息Traceback(mostrecentcalllast):File"/home/ananiev/PycharmProjects/PigLatin/main.py",

python - 为什么找不到 Python datetime time delta?

我正在尝试以mmddyyyy格式制作一组日期。日期将从当天开始,然后到future两周。所以这一切都取决于开始日期。当我运行我的代码时,我收到一条错误消息:Traceback(mostrecentcalllast):File"timeTest.py",line8,inday=datetime.timedelta(days=i)AttributeError:typeobject'datetime.datetime'hasnoattribute'timedelta'我不确定为什么会这样,因为在网上搜索后,我注意到人们以这种方式使用“timedelta”。这是我的代码:importtimef

python - 为什么 datetime.now() 和 datetime.today() 在我的电脑上显示 UTC 时间而不是本地时间?

datetime.now()和datetime.today()在我的计算机上返回UTC时间,即使thedocumentation说它们应该返回本地时间。这是我运行的脚本:#!/usr/bin/pythonimporttimeimportdatetimeif__name__=="__main__":print(datetime.datetime.now())print(datetime.datetime.today())print(datetime.datetime.fromtimestamp(time.time()))这是输出:2017-11-2922:47:35.3399142017

python - 如何直接从 datetime.datetime 子模块导入 now()

背景:我在Python程序中有几个重复调用的紧密循环,其中包括datetime.datetime.now()方法,以及datetime.datetime.min和datetime.datetime.max属性。为了优化,我想将它们导入本地命名空间,避免重复的、不必要的模块层次结构名称查找,如下所示:fromdatetime.datetimeimportnow,min,max但是,Python会提示:Traceback(mostrecentcalllast):File"my_code.py",line1,infromdatetime.datetimeimportnow,min,maxIm

Python MySQLdb 返回 datetime.date 和 decimal

我有一个MySQL查询:SELECTmydate,countryCode,qtySoldfromsalesordermydate,countryCode这将返回具有如下值的元组的元组:((datetime.date(2011,1,3),'PR',Decimal('1')),(datetime.date(2011,1,31),'MX',Decimal('1')))当我尝试使用循环打印时,它打印得非常好:2011-1-3,PR,12011-1-31,MX,1但是当我尝试返回这个值时,它返回为datetime.date(2011,1,3),'PR',Decimal('1')有没有办法获取正常

python - numpy 数组 1.9.2 获取 ValueError : could not broadcast input array from shape (4, 2) 形状 (4)

以下代码在numpy1.7.1中工作,但在当前版本中给出值错误。我想知道它的根本原因。importnumpyasnpx=[1,2,3,4]y=[[1,2],[2,3],[1,2],[2,3]]a=np.array([x,np.array(y)])以下是我在numpy1.7.1中得到的输出>>>aarray([[1,2,3,4],[array([1,2]),array([2,3]),array([1,2]),array([2,3])]],dtype=object)但相同的代码在1.9.2版本中会产生错误。---->5a=np.array([x,np.array(y)])ValueErro

python - 为什么我会收到 Keras LSTM RNN input_shape 错误?

我不断从以下代码中收到input_shape错误。fromkeras.modelsimportSequentialfromkeras.layers.coreimportDense,Activation,Dropoutfromkeras.layers.recurrentimportLSTMdef_load_data(data):"""datashouldbepd.DataFrame()"""n_prev=10docX,docY=[],[]foriinrange(len(data)-n_prev):docX.append(data.iloc[i:i+n_prev].as_matrix())