This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import pandas as pd | |
from pandas import Timestamp | |
csv = '/path/to/file/salesforce_leads.csv' | |
df = pd.read_csv(csv) # df represents a Pandas DataFrame object | |
# Format Last Modified in acceptable Pandas format | |
df['Last Modified'] = pd.to_datetime(df['Last Modified']) | |
df['Create Date'] = pd.to_datetime(df['Create Date']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> from prepare import df | |
>>> df.count() | |
Create Date 373 | |
Last Modified 373 | |
Website 261 | |
Fax 1 | |
Mobile 13 | |
Phone 253 | |
Country 187 | |
Zip/Postal Code 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> df['age'] = df['now'] - df['Create Date'] | |
>>> df['age'].mean().days |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> df['diff'] = df['now'] - df['Last Modified'] | |
>>> df['diff'].mean().days |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> from integrations.salesforce.auth import get_dev_auth_for_bulk | |
>>> auth = get_dev_auth_for_bulk() | |
>>> query = """SELECT Id, Email FROM Lead WHERE CreatedDate < 2015-12-01T23:01:01+01:00""" | |
>>> out = auth.process_SOQL_with_auth(query) | |
Traceback (most recent call last): | |
File "<console>", line 1, in <module> | |
File "/Users/joefusaro/rl_proto2/integrations/salesforce/utils.py", line 49, in process_SOQL_with_auth | |
for row in self.get_batch_results(job, batch, parse_csv=True): | |
File "/Users/joefusaro/rl_proto2/venv/lib/python2.7/site-packages/salesforce_bulk/salesforce_bulk.py", line 458, in get_batch_results | |
job_id = job_id or self.lookup_job_id(batch_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Job(models.Model): | |
""" Represents a job that is downloading, transforming or updating data as | |
part of a Program.""" | |
program = models.ForeignKey(Program) | |
# task_id ? | |
def __unicode__(self): | |
return self.id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[2015-12-11 03:16:07,804: WARNING/MainProcess] celery@Joes-MBP.home ready. | |
[2015-12-11 03:17:11,232: ERROR/MainProcess] Task program_manager.tasks.analyze_list_import_program[c2c581c1-cf92-48a8-8d29-c17c31a9f3d8] raised unexpected: WorkerLostError('Worker exited prematurely: signal 11 (SIGSEGV).',) | |
Traceback (most recent call last): | |
File "/Users/joefusaro/rl_proto2/venv/lib/python2.7/site-packages/billiard/pool.py", line 1175, in mark_as_worker_lost | |
human_status(exitcode)), | |
WorkerLostError: Worker exited prematurely: signal 11 (SIGSEGV). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nltk | |
def get_named_entities(tree, entity_label='PERSON'): | |
""" | |
Expects an nltk Tree object -OR- string. The function identifies named | |
entities (person, company or locations) and returns a list of lists. | |
entity_label can be PERSON, ORGANIZATION or GPE (Geo-Political Entity) | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[2016-01-07 18:30:40,504: WARNING/MainProcess] celery@Joes-MBP ready. | |
[2016-01-07 18:30:50,302: ERROR/MainProcess] Task program_manager.tasks.download_schema[8a92f448-4ef5-4959-b64d-283c7f5d8fa5] raised unexpected: WorkerLostError('Worker exited prematurely: signal 11 (SIGSEGV).',) | |
Traceback (most recent call last): | |
File "/Users/joefusaro/rl_proto2/venv/lib/python2.7/site-packages/billiard/pool.py", line 1175, in mark_as_worker_lost | |
human_status(exitcode)), | |
WorkerLostError: Worker exited prematurely: signal 11 (SIGSEGV). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.conf import settings | |
from django.contrib import admin | |
from django.utils.translation import ugettext_lazy as _ | |
import json | |
import requests | |
class GoToMeetingClient(models.Model): |
OlderNewer