Py学习  »  Jeff  »  全部回复
回复总数  2
9 年前
回复了 Jeff 创建的主题 » 强制退出运行python中的线程[duplicate]

可以通过在将退出线程的线程中安装跟踪来终止线程。一个可能的实现见附件链接。

Kill a thread in Python

10 年前
回复了 Jeff 创建的主题 » 在python中将时间戳转换为日期对象时出现问题[重复]

这似乎是从新纪元以来的几秒钟。

In [20]: df = DataFrame(data['values'])

In [21]: df.columns = ["date","price"]

In [22]: df
Out[22]: 
<class 'pandas.core.frame.DataFrame'>
Int64Index: 358 entries, 0 to 357
Data columns (total 2 columns):
date     358  non-null values
price    358  non-null values
dtypes: float64(1), int64(1)

In [23]: df.head()
Out[23]: 
         date  price
0  1349720105  12.08
1  1349806505  12.35
2  1349892905  12.15
3  1349979305  12.19
4  1350065705  12.15
In [25]: df['date'] = pd.to_datetime(df['date'],unit='s')

In [26]: df.head()
Out[26]: 
                 date  price
0 2012-10-08 18:15:05  12.08
1 2012-10-09 18:15:05  12.35
2 2012-10-10 18:15:05  12.15
3 2012-10-11 18:15:05  12.19
4 2012-10-12 18:15:05  12.15

In [27]: df.dtypes
Out[27]: 
date     datetime64[ns]
price           float64
dtype: object