Please help contribute to the Reddit categorization project here


    + friends - friends
    17,909 link karma
    9,087 comment karma
    send message redditor for

    [–] Convert Pandas series to list of state transitions lieutenant_lowercase 2 points ago in learnpython

    min, max and difference of these for the index for each value? Assumes sorted in order and each value doesn't appear more than once in a run

    df_pivot = df.reset_index().pivot_table(index='gender', values='index', aggfunc=('min', 'max'))
    df_pivot['length'] = df_pivot['max'] - df_pivot['min']

    [–] Brandon Rhodes PANDAS tutorial lieutenant_lowercase 3 points ago in learnpython

    If I was you I wouldn't use a tutorial that old. Try and find something more up to date. Syntax has changed quite a bit

    [–] Using youtube-dl to scrape only certain files. lieutenant_lowercase 1 points ago * (lasted edited 7 days ago) in learnpython

    You could do this very easily yourself with requests. Something like this would work:

    import requests
    from tqdm import tqdm
    client_id = 'XXX'
    user_id = '1819173'
    url = "{}/tracks"
    querystring = {"representation":"","client_id":client_id,
    next_page = None
    tracks = []
    while True:
        if next_page == None:
            r = requests.get(url.format(user_id ), headers=headers, params=querystring)
            r = requests.get(next_page, headers=headers, params=querystring)
        tracks += r.json()['collection']
        next_page = r.json()['next_href']
        if next_page == None:
    API_URL = '{}/streams?client_id={}'
    for track in tqdm(tracks):
        if 'Podcast' in track['title']:
            r = requests.get(API_URL.format(track['id'], client_id))
            track['mp3_url'] = r.json()['http_mp3_128_url']
            r = requests.get(track['mp3_url'])
            open(r'data\{}.mp3'.format(track['title'].replace(':','')), 'wb').write(r.content)

    [–] Using youtube-dl to scrape only certain files. lieutenant_lowercase 2 points ago in learnpython

    Why would you use youtube-dl to scrape soundcloud? Have you tried googling this? I've just googled "python download tracks from soundcloud" and there are tons of examples?

    [–] Found another one lieutenant_lowercase 3 points ago in london

    There’s another one in shoreditch - “chat to a roadman” or something

    [–] Implied Passing signal lieutenant_lowercase 15 points ago in CFA

    Put your tin foil hat away and chill out

    [–] Meeting up to study CFA Level I (London) lieutenant_lowercase 2 points ago in CFA

    There is so much material at Level 1, none of which is particularly difficult, I would question the merits of group study. I'd suggest just finding somewhere quiet where you can study in peace for a few hours. If you get stuck on anything just ask on the subreddit or watch some videos.

    My 2 cents

    [–] I am literally cursed lieutenant_lowercase 2 points ago in RocketLeague

    Work on your defence sounds like you are getting countered

    [–] Found this cryptic message on the train to Waterloo. Anyone know what it is? lieutenant_lowercase 58 points ago * (lasted edited 10 days ago) in london

    Looks like hex. 0D 0A is line break.

    0D 0A 5E 58 41 0D 0A 5E 4D 4D 54 0D 0A 5E 50 57 36 30 
    39 0D 0A 5E 4C 4C 30 34 30 36 0D 0A 5E 4C 53 30 0D 0A
    5E 46 4F 31 39 32 2C 32 38 38 5E 47 46 41 2C 30 33 33
    32 38 2C 30 33 33 32 38 2C 30 30 30 35 32 2C 3A 5A 36
    34 3A 0A 65 4A 7A 74 6C 4C 47 4B 33 44 41 51 68 73 64

    Converted to Hex it is:


    Which looks to be ZPL printer command (

    [–] Scraping images from imgur using selenium and requests lieutenant_lowercase 2 points ago in learnpython

    Selenium is excessive. Easier just to parse the JSON array in the HTML

    import json
    import requests
    r = requests.get('')
    json_data = r.text.split('image               : ')[1].split('group')[0].strip()[:-1]
    json_data = json.loads(json_data)
    images = json_data['album_images']['images']

    which gives you JSON containing all the information:

    [{'animated': False,
      'datetime': '2013-12-11 07:04:16',
      'description': None,
      'ext': '.jpg',
      'has_sound': False,
      'hash': 'cjPnOhL',
      'height': 1080,
      'looping': False,
      'prefer_video': False,
      'size': 357706,
      'title': '',
      'width': 1920},
     {'animated': False,
      'datetime': '2013-12-11 07:04:27',
      'description': None,
      'ext': '.jpg',
      'has_sound': False,
      'hash': 'HlmWDMU',
      'height': 1839,
      'looping': False,
      'prefer_video': False,
      'size': 933287,
      'title': '',
      'width': 2989},
     {'animated': False,
      'datetime': '2013-12-11 07:04:29',
      'description': None,
      'ext': '.jpg',
      'has_sound': False,
      'hash': 'gUMHWvP',
      'height': 1050,
      'looping': False,
      'prefer_video': False,
      'size': 108970,
      'title': '',
      'width': 1680},
     {'animated': False,
      'datetime': '2013-12-11 07:04:37',
      'description': None,
      'ext': '.jpg',
      'has_sound': False,
      'hash': 'mpHgYA0',
      'height': 1080,
      'looping': False,
      'prefer_video': False,
      'size': 771387,
      'title': '',
      'width': 1920},

    [–] Official apology lieutenant_lowercase 5 points ago in CFA

    I find it hard to believe your not 12 years old

    [–] Stuck on how to scrape a web-page with a JavaScript form lieutenant_lowercase 2 points ago in learnpython

    Use chrome developer console to look at the requests the site is sending, then just recreate those.

    [–] Team up with AI bots lieutenant_lowercase 1 points ago in RocketLeague

    Play the game a little more and you will realise how awful the bots are. I could win 1v10 bots on my own

    [–] How to open a PDF to a specific page in chrome? lieutenant_lowercase 1 points ago in learnpython

    Have you tried adding


    to the filename?