In [2]:
%load_ext cypher


/home/davebshow/.virtualenvs/scientific3/lib/python3.4/site-packages/IPython/config.py:13: ShimWarning: The `IPython.config` package has been deprecated. You should import from traitlets.config instead.
  "You should import from traitlets.config instead.", ShimWarning)
/home/davebshow/.virtualenvs/scientific3/lib/python3.4/site-packages/IPython/utils/traitlets.py:5: UserWarning: IPython.utils.traitlets has moved to a top-level traitlets package.
  warn("IPython.utils.traitlets has moved to a top-level traitlets package.")

In [3]:
query = """
match (t:tweet)-[r]-(:tweet)
where t.lang is not null and n.lang is not null
return collect(t) as top_tweets, count(r) as deg
order by deg 
limit 5
"""

query2 = """
match (t:tweet)-[r]-(:tweet)
where t.lang is not null
with t, count(r) as deg
order by deg desc
limit 50000
match rels=(t)--(t)
return rels
"""

edges_query = """
match (t:tweet)-[:USES]->(h:hashtag)
where t.coordinates is not null
with h, collect(t.tid) as tweets
return h, tweets
"""

In [6]:
top_tweets = %cypher match (t:tweet)-[r]-(:tweet) where t.lang is not null return t as top_tweets, count(r) as deg order by deg desc limit 5


5 rows affected.

In [8]:
top_tweets


Out[8]:
top_tweets deg
{'created_at': 'Sat Nov 14 11:47:14 +0000 2015', 'clean_text': 'Thoughts go out to everyone in Paris .', 'lang': 'en', 'subjectivity': 0.0, 'text': 'Thoughts go out to everyone in Paris . #prayforparis', 'polarity': 0.0, 'tid': '665496205854687232'} 38199
{'created_at': 'Sat Nov 14 00:15:05 +0000 2015', 'clean_text': 'thoughts and prayers for those people involved in the situation that has occurred in Paris this evening .. Very sad 🇫🇷', 'lang': 'en', 'subjectivity': 1.0, 'text': 'thoughts and prayers for those people involved in the situation that has occurred in Paris this evening .. Very sad 🇫🇷', 'polarity': -0.65, 'tid': '665322019291013120'} 27827
{'created_at': 'Fri Nov 13 21:45:18 +0000 2015', 'clean_text': 'Thinking of everyone in Paris.', 'lang': 'en', 'subjectivity': 0.0, 'text': 'Thinking of everyone in Paris.', 'polarity': 0.0, 'tid': '665284325542371329'} 22158
{'created_at': 'Sat Nov 14 01:05:30 +0000 2015', 'clean_text': 'Had a great first show but just heard about what happened in Paris. Thoughts and prayers with everyone', 'lang': 'en', 'subjectivity': 0.5416667, 'text': 'Had a great first show but just heard about what happened in Paris. Thoughts and prayers with everyone #PrayForParis', 'polarity': 0.525, 'tid': '665334709996523520'} 17657
{'created_at': 'Sat Nov 14 01:13:44 +0000 2015', 'clean_text': 'all of my love and prayers go out to paris tonight.', 'lang': 'en', 'subjectivity': 0.6, 'text': 'all of my love and prayers go out to paris tonight.', 'polarity': 0.5, 'tid': '665336782418919425'} 16860

In [ ]:


In [ ]:


In [16]:
top_tweet_rels = %cypher match (t:tweet)-[r]-(:tweet) where t.lang is not null with t, collect(t) as tweets, count(r) as deg order by deg desc limit 50000 match rels=(t)--(r:tweet) where r in tweets return rels


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/home/davebshow/.virtualenvs/scientific3/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, **httplib_request_kw)
    375             try:  # Python 2.7, use buffering of HTTP responses
--> 376                 httplib_response = conn.getresponse(buffering=True)
    377             except TypeError:  # Python 2.6 and older

TypeError: getresponse() got an unexpected keyword argument 'buffering'

During handling of the above exception, another exception occurred:

KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-16-441700e36690> in <module>()
----> 1 top_tweet_rels = get_ipython().magic('cypher match (t:tweet)-[r]-(:tweet) where t.lang is not null with t, collect(t) as tweets, count(r) as deg order by deg desc limit 50000 match rels=(t)--(r:tweet) where r in tweets return rels')

/home/davebshow/.virtualenvs/scientific3/lib/python3.4/site-packages/IPython/core/interactiveshell.py in magic(self, arg_s)
   2334         magic_name, _, magic_arg_s = arg_s.partition(' ')
   2335         magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2336         return self.run_line_magic(magic_name, magic_arg_s)
   2337 
   2338     #-------------------------------------------------------------------------

/home/davebshow/.virtualenvs/scientific3/lib/python3.4/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line)
   2255                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2256             with self.builtin_trap:
-> 2257                 result = fn(*args,**kwargs)
   2258             return result
   2259 

/home/davebshow/.virtualenvs/scientific3/lib/python3.4/site-packages/cypher/magic.py in execute(self, line, cell, local_ns)

/home/davebshow/.virtualenvs/scientific3/lib/python3.4/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
    191     # but it's overkill for just that one bit of state.
    192     def magic_deco(arg):
--> 193         call = lambda f, *a, **k: f(*a, **k)
    194 
    195         if callable(arg):

/home/davebshow/.virtualenvs/scientific3/lib/python3.4/site-packages/cypher/magic.py in execute(self, line, cell, local_ns)

/home/davebshow/.virtualenvs/scientific3/lib/python3.4/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
    191     # but it's overkill for just that one bit of state.
    192     def magic_deco(arg):
--> 193         call = lambda f, *a, **k: f(*a, **k)
    194 
    195         if callable(arg):

/home/davebshow/.virtualenvs/scientific3/lib/python3.4/site-packages/cypher/magic.py in execute(self, line, cell, local_ns)
    106             return self._persist_dataframe(parsed['cypher'], conn, user_ns)
    107         try:
--> 108             result = run(parsed['cypher'], user_ns, self, conn)
    109             return result
    110         except StatusException as e:

/home/davebshow/.virtualenvs/scientific3/lib/python3.4/site-packages/cypher/run.py in run(query, params, config, conn, **kwargs)
    507         params = extract_params_from_query(query, params)
    508         result = conn.session.query(query, params,
--> 509                                     data_contents=config.data_contents)
    510         if config.feedback:
    511             print(interpret_stats(result))

/home/davebshow/.virtualenvs/scientific3/lib/python3.4/site-packages/neo4jrestclient/client.py in query(self, q, params, returns, data_contents, tx)
    210                 self._cypher, self._auth, q=q, params=params,
    211                 types=types, returns=returns, data_contents=data_contents,
--> 212                 tx=tx
    213             )
    214             if tx is not None and tx.id in self._transactions:

/home/davebshow/.virtualenvs/scientific3/lib/python3.4/site-packages/neo4jrestclient/query.py in __init__(self, cypher, auth, q, params, types, returns, lazy, data_contents, tx)
    322             tx.append(q=self.q, params=self.params, returns=self._returns,
    323                       data_contents=data_contents, obj=self)
--> 324             tx.execute()
    325         elif not lazy:
    326             self._get_elements()

/home/davebshow/.virtualenvs/scientific3/lib/python3.4/site-packages/neo4jrestclient/query.py in execute(self)
    934         if self.auto_execute:
    935             self.url_commit = None
--> 936             return self.commit()
    937         if not self.url_tx:
    938             self._begin()

/home/davebshow/.virtualenvs/scientific3/lib/python3.4/site-packages/neo4jrestclient/query.py in commit(self)
    946         else:
    947             url = u"{}/commit".format(self.url_begin)
--> 948         results = self._execute(url, results=True)
    949         self.finished = True
    950         return results

/home/davebshow/.virtualenvs/scientific3/lib/python3.4/site-packages/neo4jrestclient/query.py in _execute(self, url, results)
    863 
    864     def _execute(self, url, results=True):
--> 865         response = self._request(url, statements=self.statements)
    866         content = response.json()
    867         self._manage_errors(content["errors"])

/home/davebshow/.virtualenvs/scientific3/lib/python3.4/site-packages/neo4jrestclient/query.py in _request(self, url, statements)
    856             "statements": statements
    857         }
--> 858         response = request.post(url, data=data)
    859         if response.status_code in [200, 201]:
    860             return response

/home/davebshow/.virtualenvs/scientific3/lib/python3.4/site-packages/neo4jrestclient/request.py in post(self, url, data, headers)
     68         Returns the response object.
     69         """
---> 70         return self._request('POST', url, data, headers=headers)
     71 
     72     def put(self, url, data, headers=None):

/home/davebshow/.virtualenvs/scientific3/lib/python3.4/site-packages/neo4jrestclient/request.py in _request(self, method, url, data, headers)
    196             response = getattr(session, method)(root_uri, headers=headers,
    197                                                 data=data, cert=cert,
--> 198                                                 auth=auth, verify=verify)
    199             if response.status_code == 401:
    200                 raise StatusException(401, "Authorization Required")

/home/davebshow/.virtualenvs/scientific3/lib/python3.4/site-packages/requests/sessions.py in post(self, url, data, json, **kwargs)
    509         """
    510 
--> 511         return self.request('POST', url, data=data, json=json, **kwargs)
    512 
    513     def put(self, url, data=None, **kwargs):

/home/davebshow/.virtualenvs/scientific3/lib/python3.4/site-packages/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    466         }
    467         send_kwargs.update(settings)
--> 468         resp = self.send(prep, **send_kwargs)
    469 
    470         return resp

/home/davebshow/.virtualenvs/scientific3/lib/python3.4/site-packages/requests/sessions.py in send(self, request, **kwargs)
    574 
    575         # Send the request
--> 576         r = adapter.send(request, **kwargs)
    577 
    578         # Total elapsed time of the request (approximately)

/home/davebshow/.virtualenvs/scientific3/lib/python3.4/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    368                     decode_content=False,
    369                     retries=self.max_retries,
--> 370                     timeout=timeout
    371                 )
    372 

/home/davebshow/.virtualenvs/scientific3/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, **response_kw)
    557             httplib_response = self._make_request(conn, method, url,
    558                                                   timeout=timeout_obj,
--> 559                                                   body=body, headers=headers)
    560 
    561             # If we're going to release the connection in ``finally:``, then

/home/davebshow/.virtualenvs/scientific3/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, **httplib_request_kw)
    376                 httplib_response = conn.getresponse(buffering=True)
    377             except TypeError:  # Python 2.6 and older
--> 378                 httplib_response = conn.getresponse()
    379         except (SocketTimeout, BaseSSLError, SocketError) as e:
    380             self._raise_timeout(err=e, url=url, timeout_value=read_timeout)

/usr/lib/python3.4/http/client.py in getresponse(self)
   1169 
   1170         try:
-> 1171             response.begin()
   1172             assert response.will_close != _UNKNOWN
   1173             self.__state = _CS_IDLE

/usr/lib/python3.4/http/client.py in begin(self)
    349         # read until we get a non-100 response
    350         while True:
--> 351             version, status, reason = self._read_status()
    352             if status != CONTINUE:
    353                 break

/usr/lib/python3.4/http/client.py in _read_status(self)
    311 
    312     def _read_status(self):
--> 313         line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
    314         if len(line) > _MAXLINE:
    315             raise LineTooLong("status line")

/usr/lib/python3.4/socket.py in readinto(self, b)
    372         while True:
    373             try:
--> 374                 return self._sock.recv_into(b)
    375             except timeout:
    376                 self._timeout_occurred = True

KeyboardInterrupt: 

In [ ]: