Posts

Showing posts from December, 2017

Cannot create AWS SNS Platform Application for Apple Push Notification

Image
AWS SNS's help( http://docs.aws.amazon.com/ja_jp/sns/latest/dg/mobile-push-apns.html ) is detailed, but actual steps are rather vague. Exact steps are thease create certificate signing request.certSigningRequest on Keychain.app upload certificate signing request file. Then create and download aps.cer(APNS SSL certificate) from Apple Developer. Double click aps.cer and confirm Apple Push Services is added to KeyChain Right click the Keychain's item and write to .p12 file with your new password On AWS SNS Dashboard, click "Create AWS SNS Platform Application", choose previous p12 file and password for the certification① Push "read certification from file" button② fills two text fields below, and now you can push the "create" button at the bottom③ sorry for Japanese screen shot

Getting valid time spans from timestamped data using Python Pandas.

Assume we have a Panda's DataFrame indexed by a time. 2017-12-15 00:00:00 ..... 2017-12-15 00:00:15 ..... 2017-12-15 00:00:29 ..... 2017-12-15 00:00:46 ..... 2017-12-15 03:31:01 ..... 2017-12-15 03:31:17 ..... 2017-12-15 03:31:29 ..... 2017-12-15 03:32:16 ..... And if we want to get time spans from the data under condition that if rows' intervals is less than threashold, make it one span. start end 2017-12-15 00:00:00 2017-12-15 00:00:46 2017-12-15 03:31:01 2017-12-15 03:32:16 you can do it by import pandas as pd from datetime import timedelta threashold = timedelta(seconds=30) df = pd.read_csv("original_data.csv") intervals = df_origin.index[1:] - df_origin.index[:-1] df[HEAD][1:] = intervals > threshold df[TAIL][:-1] = intervals > threashold df[HEAD][0] = True df[TAIL][-1] = True _df = df[df["HEAD"] ^ df["TAIL"]] result = pd.DataFrame({"start":_df[_df["HEAD"]].index, "end":_df[_df[&q