Skip to content

Instantly share code, notes, and snippets.

@den-run-ai
Created April 20, 2017 19:28
Show Gist options
  • Save den-run-ai/d6da3c6fd2b32e5305845581b1aa513a to your computer and use it in GitHub Desktop.
Save den-run-ai/d6da3c6fd2b32e5305845581b1aa513a to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import xlwings as xw\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"array(['2005-02-01T00:00', '2005-02-01T00:01', '2005-02-01T00:02', ...,\n",
" '2005-02-28T23:57', '2005-02-28T23:58', '2005-02-28T23:59'], dtype='datetime64[m]')"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dt1 = np.arange('2005-02', '2005-03', dtype='datetime64[m]')\n",
"dt1"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"array(['2005-02-01T00:00:00.000000000', '2005-02-01T00:01:00.000000000',\n",
" '2005-02-01T00:02:00.000000000', ...,\n",
" '2005-02-28T23:57:00.000000000', '2005-02-28T23:58:00.000000000',\n",
" '2005-02-28T23:59:00.000000000'], dtype='datetime64[ns]')"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dt2 = dt1.astype('<M8[ns]')\n",
"dt2"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"xw = xw.Book()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"xw.sheets[0].range(\"A1\").options(transpose=True).value = dt1 #ok\n",
"xw.sheets[0].range(\"B1\").options(transpose=True).value = dt2 #problem"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.13"
},
"latex_envs": {
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 0
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment