A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
| import ctypes | |
| import ctypes.wintypes | |
| import win32con | |
| class GlobalHotKeys(object): | |
| """ | |
| Register a key using the register() method, or using the @register decorator | |
| Use listen() to start the message pump |
| --- a/setup.py 2014-03-17 03:31:31.000000000 +0100 | |
| +++ b/setup.py 2014-03-17 19:06:03.000000000 +0100 | |
| @@ -750,10 +750,8 @@ | |
| exts.append( Extension('_socket', ['socketmodule.c'], | |
| depends = ['socketmodule.h']) ) | |
| # Detect SSL support for the socket module (via _ssl) | |
| - search_for_ssl_incs_in = [ | |
| - '/usr/local/ssl/include', | |
| - '/usr/contrib/ssl/include/' | |
| - ] |
This example pulls together various examples of work with trees in D3.js.
The panning functionality can certainly be improved in my opinion and I would be thrilled to see better solutions contributed.
One can do all manner of housekeeping or server related calls on the drop event to manage a remote tree dataset for example.
Dragging can be performed on any node other than root (flare). Dropping can be done on any node.
Panning can either be done by dragging an empty part of the SVG around or dragging a node towards an edge.
| # Copyright (c) 2013 Georgios Gousios | |
| # MIT-licensed | |
| create database stackoverflow DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; | |
| use stackoverflow; | |
| create table badges ( | |
| Id INT NOT NULL PRIMARY KEY, | |
| UserId INT, |
| import math | |
| from text.blob import TextBlob as tb | |
| def tf(word, blob): | |
| return blob.words.count(word) / len(blob.words) | |
| def n_containing(word, bloblist): | |
| return sum(1 for blob in bloblist if word in blob) | |
| def idf(word, bloblist): |
Original post at: http://pythonexcels.com/python-excel-mini-cookbook/
To get you started, I’ve illustrated a number of common tasks you can do with Python and Excel. Each program below is a self contained example, just copy it, paste it and run it. A few things to note:
These examples were tested in Excel 2007, they should work fine in earlier versions as well after changing the extension of the file within the wb.SaveAs() statement from .xlsx to .xls
If you’re new to this, I recommend typing these examples by hand into IDLE, IPython or the Python interpreter, then watching the effect in Excel as you enter the commands. To make Excel visible add the line excel.Visible = True after the excel =win32.gencache.EnsureDispatch('Excel.Application') line in the script
These are simple examples with no error checking. Make sure the output files doesn’t exist before running the script. If the script crashes, it may leave a copy of Excel running in the background. Open the Windows T
| Country | CountryCode | Currency | Code | |
|---|---|---|---|---|
| New Zealand | NZ | New Zealand Dollars | NZD | |
| Cook Islands | CK | New Zealand Dollars | NZD | |
| Niue | NU | New Zealand Dollars | NZD | |
| Pitcairn | PN | New Zealand Dollars | NZD | |
| Tokelau | TK | New Zealand Dollars | NZD | |
| Australian | AU | Australian Dollars | AUD | |
| Christmas Island | CX | Australian Dollars | AUD | |
| Cocos (Keeling) Islands | CC | Australian Dollars | AUD | |
| Heard and Mc Donald Islands | HM | Australian Dollars | AUD |
| # | |
| # Copyright (C) 2013-2020 Vinay Sajip. New BSD License. | |
| # | |
| import os | |
| import os.path | |
| from subprocess import Popen, PIPE | |
| import sys | |
| from threading import Thread | |
| from urllib.parse import urlparse | |
| from urllib.request import urlretrieve |
| # | |
| # conditionalformatting.py | |
| # Create two tables and apply Conditional Formatting | |
| # | |
| import win32com.client as win32 | |
| excel = win32.gencache.EnsureDispatch('Excel.Application') | |
| #excel.Visible = True | |
| wb = excel.Workbooks.Add() | |
| ws = wb.Worksheets('Sheet1') | |
| ws.Range("B2:K2").Value = [i for i in range(1,11)] |