This file contains hidden or 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
| # List unique values in a DataFrame column | |
| pd.unique(df.column_name.ravel()) | |
| # Convert Series datatype to numeric, getting rid of any non-numeric values | |
| df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True) | |
| # Grab DataFrame rows where column has certain values | |
| valuelist = ['value1', 'value2', 'value3'] | |
| df = df[df.column.isin(valuelist)] |
This file contains hidden or 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
| # [How to add an image to a gist](https://remarkablemark.org/blog/2016/06/16/how-to-add-image-to-gist/) | |
| 1. Create or find a [gist](https://gist.github.com) that you own. | |
| 2. Clone your gist (replace `<hash>` with your gist's hash): | |
| ```sh | |
| # with ssh | |
| git clone [email protected]:<hash>.git mygist | |
| # with https | |
| git clone https://gist.github.com/<hash>.git mygist |
This file contains hidden or 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
| { | |
| "created_at": "Thu Mar 15 23:17:12 +0000 2018", | |
| "id": 974424304560590848, | |
| "id_str": "974424304560590848", | |
| "text": "RT @abinneheet: @twcdaveschwartz القصيم كنز يبحث عن من يكتشفه وسمو امير المنطقة المحبوب الامير الدكتور فيصل بن مشعل اكبر داعم وصانع للفرص ب…", | |
| "truncated": false, | |
| "entities": { | |
| "hashtags": [], | |
| "symbols": [], | |
| "user_mentions": [ |
This file contains hidden or 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
| { | |
| "created_at": "Mon Feb 13 10:32:29 +0000 2012", | |
| "id": 169006017261219840, | |
| "id_str": "169006017261219840", | |
| "text": "RT @SivartDeshawn: Jada Pinkett in \"A Low Down Dirty Shame\"...haha love her.", | |
| "truncated": false, | |
| "entities": { | |
| "hashtags": [], | |
| "symbols": [], | |
| "user_mentions": [], |
This file contains hidden or 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
| { | |
| "created_at": "Mon Feb 13 10:32:29 +0000 2012", | |
| "id": 169006017261219840, | |
| "id_str": "169006017261219840", | |
| "text": "RT @SivartDeshawn: Jada Pinkett in \"A Low Down Dirty Shame\"...haha love her.", | |
| "truncated": false, | |
| "entities": { | |
| "hashtags": [], | |
| "symbols": [], | |
| "user_mentions": [], |
This file contains hidden or 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
| { | |
| "created_at": "Mon Sep 27 19:06:05 +0000 2010", | |
| "id": 25712847277, | |
| "id_str": "25712847277", | |
| "text": "This Tweet from @benshapiro has been withheld in Germany, France based on local law(s). Learn more.", | |
| "truncated": false, | |
| "entities": { | |
| "hashtags": [], | |
| "symbols": [], | |
| "user_mentions": [], |
This file contains hidden or 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
| {"help":{},"notifications":{},"search":{},"user":{},"about":{},"activity":{"list":[{"id":"58e254099261d229616c2846","api":{"privacy":"public","created_at":"2016-06-09T12:41:46.586Z","logo":"https://web.archive.org/web/20170423142454/https://c.hitchhq.net/-/logos/5853d667dc99eb000f4f05d6","name":"Twitter","slug":"twitter","published":true,"owner":"hitch","media_type":"api","capabilities":["support","web-assistant"],"assistant_token":"d8a799cc09fd290dcf8e2d31c587264f383aef33078cb9f3a6a21dd4eed89044","machine_readable_url":"https://web.archive.org/web/20170423142454/https://trello-attachments.s3.amazonaws.com/5841a5a6e86182bb8a4f2bb8/58987c5306ed9f47815c036c/696a4365bdb0a4f676b2eca8c9561f24/twitter.json","website":"https://web.archive.org/web/20170423142454/https://dev.twitter.com/","id":"5759640a27ae7e100025908a","description":"Real-time information network.","team":""},"activity":{"name":"GET accounts/:account_id/features Twitter Developers","published":"2017-04-03T13:51:35.841Z","url":"https://web.archive.or |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| # This small script shows how to deconstruct a Twitter tweet id into its | |
| # various components. The tweet_components method accepts a tweet id and | |
| # returns a dict object with key / values representing the various | |
| # components of a tweet id. Each component has its own method detailing | |
| # how values are extracted from the tweet id. | |
| def melt_snowflake(snowflake_id): | |
| """return tuple of snowflake components given a tweet id""" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
| # Author: Qiushi Pan (@qqhann) | |
| # This is a code snippet with sample usage, to get replies to a specific tweet. | |
| # ===== | |
| import tweepy | |
| import time | |
| import os | |
| from collections import defaultdict | |
| from dotenv import load_dotenv, find_dotenv | |
| env = load_dotenv(find_dotenv(), override=True) |