My problem is that the Microsoft Graph findMeetingTimes API is not sorting the meeting time suggestions like I would expect it.
In the documentation it says:
If there are multiple meeting time suggestions, the findMeetingTimes
action first orders the suggestions by their computed confidence value
from high to low. If there are suggestions with the same confidence,
the action then orders these suggestions chronologically.
But whenever I try the API I get a "meetingTimeSuggestionsResult" sorted like this one:
Confidence: 100 || 24.08.2017 16:30:00 -> 24.08.2017 17:00:00
Confidence: 100 || 24.08.2017 16:00:00 -> 24.08.2017 16:30:00
Confidence: 100 || 24.08.2017 08:30:00 -> 24.08.2017 09:00:00
Confidence: 100 || 24.08.2017 09:00:00 -> 24.08.2017 09:30:00
Confidence: 100 || 24.08.2017 14:00:00 -> 24.08.2017 14:30:00
Confidence: 100 || 24.08.2017 14:30:00 -> 24.08.2017 15:00:00
Confidence: 50 || 24.08.2017 13:00:00 -> 24.08.2017 13:30:00
Confidence: 50 || 24.08.2017 13:30:00 -> 24.08.2017 14:00:00
Confidence: 50 || 24.08.2017 15:00:00 -> 24.08.2017 15:30:00
Confidence: 100 || 24.08.2017 11:30:00 -> 24.08.2017 12:00:00
Confidence: 100 || 24.08.2017 10:30:00 -> 24.08.2017 11:00:00
Confidence: 100 || 24.08.2017 11:00:00 -> 24.08.2017 11:30:00
Confidence: 100 || 24.08.2017 10:00:00 -> 24.08.2017 10:30:00
Confidence: 100 || 24.08.2017 09:30:00 -> 24.08.2017 10:00:00
Confidence: 100 || 24.08.2017 12:30:00 -> 24.08.2017 13:00:00
Confidence: 50 || 24.08.2017 15:30:00 -> 24.08.2017 16:00:00
Confidence: 100 || 24.08.2017 12:00:00 -> 24.08.2017 12:30:00
The documentation is outdated. That's the way the API used to work, but it was changed and unfortunately the doc wasn't updated.
Instead of a simple sort chronologically, the API tries to be "smart" about how it orders the results. There are a number of factors that go into it, with a major one being the user's past behavior. Showing a tendency to meet at certain times of the day can up that in the ranking.
I am getting nil for some values while using dateFromString in swift. I searched a lot but in vain.
Following is my code:
let strDate = self.sortedDict.valueForKey("TIME").objectAtIndex(indexPath.row).objectAtIndex(0) as? String
print(strDate);
let st_date = frmt.dateFromString(strDate!)
let frmt1:NSDateFormatter = NSDateFormatter()
frmt1.locale = NSLocale(localeIdentifier: localeStr)
frmt1.dateFormat = "MMM, dd yyyy hh:mm a"
if st_date != nil {
print(st_date)
}
Output console:
Optional("September, 20 2015 10:00:00")
Optional(2015-09-20 10:00:00 +0000)
Optional("October, 04 2015 10:00:00")
Optional(2015-10-04 10:00:00 +0000)
Optional("October, 04 2015 14:00:00") // nil
Optional("October, 18 2015 15:00:00") // nil
Optional("September, 20 2015 14:00:00") // nil
Optional("September, 27 2015 10:00:00")
Optional(2015-09-27 10:00:00 +0000)
Optional("September, 27 2015 12:00:00")
Optional(2015-09-27 00:00:00 +0000)
Optional("September, 27 2015 14:00:00")
Optional("October, 03 2015 14:00:00") //nil
Optional("October, 03 2015 16:00:00") //nil
The format is same for all date strings still I get nil for few values. Why so? Please help. Where am I getting wrong?
format should be HH for 24 hours even you are getting values only for 12 hours.
frmt1.dateFormat = "MMM, dd yyyy HH:mm a"
How do I print only the text from the json. I am working on ruby on rails app.
tweets = JSON.parse(response.body)
tweets.each do |tweet|
"#{tweet["text"]}"
end
I tried the above code bt it displays the whole json.
Response.body :
[{"created_at"=>"Mon Jun 09 02:49:17 +0000 2014",
"id"=>475831972812423168, "id_str"=>"475831972812423168",
"text"=>"#debalec #DIST1", "source"=>"https://dev.twitter.com/docs/tfw\" rel=\"nofollow\">Twitter for
Websites", "truncated"=>false, "in_reply_to_status_id"=>nil,
"in_reply_to_status_id_str"=>nil, "in_reply_to_user_id"=>2551123651,
"in_reply_to_user_id_str"=>"2551123651",
"in_reply_to_screen_name"=>"debalec", "user"=>{"id"=>1551421092,
"id_str"=>"1551421092", "name"=>"The Third",
"screen_name"=>"thethird", "location"=>"", "description"=>"",
"url"=>nil, "entities"=>{"description"=>{"urls"=>[]}},
"protected"=>false, "followers_count"=>12, "friends_count"=>199,
"listed_count"=>0, "created_at"=>"Thu Jun 27 20:24:56 +0000 2013",
"favourites_count"=>54, "utc_offset"=>nil, "time_zone"=>nil,
"geo_enabled"=>false, "verified"=>false, "statuses_count"=>82,
"lang"=>"en", "contributors_enabled"=>false, "is_translator"=>false,
"is_translation_enabled"=>false, "profile_background_color"=>"59BEE4",
"profile_background_image_url"=>"http://pbs.twimg.com/profile_background_images/378800000083038715/7b1cad0896d22d75b85f5f86fc69b59f.jpeg",
"profile_background_image_url_https"=>"https://pbs.twimg.com/profile_background_images/378800000083038715/7b1cad0896d22d75b85f5f86fc69b59f.jpeg",
"profile_background_tile"=>false,
"profile_image_url"=>"http://abs.twimg.com/sticky/default_profile_images/default_profile_4_normal.png",
"profile_image_url_https"=>"https://abs.twimg.com/sticky/default_profile_images/default_profile_4_normal.png",
"profile_link_color"=>"8FCAE0",
"profile_sidebar_border_color"=>"4BB7DF",
"profile_sidebar_fill_color"=>"191F22",
"profile_text_color"=>"4BB7DF", "profile_use_background_image"=>true,
"default_profile"=>false, "default_profile_image"=>true,
"following"=>false, "follow_request_sent"=>false,
"notifications"=>false}, "geo"=>nil, "coordinates"=>nil, "place"=>nil,
"contributors"=>nil, "retweet_count"=>0, "favorite_count"=>0,
"entities"=>{"hashtags"=>[{"text"=>"DIST1", "indices"=>[10, 16]}],
"symbols"=>[], "urls"=>[],
"user_mentions"=>[{"screen_name"=>"debalec", "name"=>"DebaElec",
"id"=>2551123651, "id_str"=>"2551123651", "indices"=>[0, 8]}]},
"favorited"=>false, "retweeted"=>false, "lang"=>"und"},
{"created_at"=>"Fri Jun 06 22:41:39 +0000 2014",
"id"=>475044876841938944, "id_str"=>"475044876841938944", "text"=>"hi
#debalec", "source"=>"http://twitter.com/download/android\"
rel=\"nofollow\">Twitter for Android", "truncated"=>false,
"in_reply_to_status_id"=>nil, "in_reply_to_status_id_str"=>nil,
"in_reply_to_user_id"=>nil, "in_reply_to_user_id_str"=>nil,
"in_reply_to_screen_name"=>nil, "user"=>{"id"=>1551421092,
"id_str"=>"1551421092", "name"=>"the third",
"screen_name"=>"the third", "location"=>"", "description"=>"",
"url"=>nil, "entities"=>{"description"=>{"urls"=>[]}},
"protected"=>false, "followers_count"=>12, "friends_count"=>199,
"listed_count"=>0, "created_at"=>"Thu Jun 27 20:24:56 +0000 2013",
"favourites_count"=>54, "utc_offset"=>nil, "time_zone"=>nil,
"geo_enabled"=>false, "verified"=>false, "statuses_count"=>82,
"lang"=>"en", "contributors_enabled"=>false, "is_translator"=>false,
"is_translation_enabled"=>false, "profile_background_color"=>"59BEE4",
"profile_background_image_url"=>"http://pbs.twimg.com/profile_background_images/378800000083038715/7b1cad0896d22d75b85f5f86fc69b59f.jpeg","profile_background_image_url_https"=>"https://pbs.twimg.com/profile_background_images/378800000083038715/7b1cad0896d22d75b85f5f86fc69b59f.jpeg",
"profile_background_tile"=>false,"profile_image_url"=>"http://abs.twimg.com/sticky/default_profile_images/default_profile_4_normal.png","profile_image_url_https"=>"https://abs.twimg.com/sticky/default_profile_images/default_profile_4_normal.png",
"profile_link_color"=>"8FCAE0",
"profile_sidebar_border_color"=>"4BB7DF",
"profile_sidebar_fill_color"=>"191F22",
"profile_text_color"=>"4BB7DF", "profile_use_background_image"=>true,
"default_profile"=>false, "default_profile_image"=>true,
"following"=>false, "follow_request_sent"=>false,
"notifications"=>false}, "geo"=>nil, "coordinates"=>nil, "place"=>nil,
"contributors"=>nil, "retweet_count"=>0, "favorite_count"=>0,
"entities"=>{"hashtags"=>[], "symbols"=>[], "urls"=>[],
"user_mentions"=>[{"screen_name"=>"debalec", "name"=>"DebaElec",
"id"=>2551123651, "id_str"=>"2551123651", "indices"=>[3, 11]}]},
"favorited"=>false, "retweeted"=>false, "lang"=>"und"}]
Use map instead of each:
tweets = JSON.parse(response.body)
tweets.map do |tweet|
tweet["text"]
end
And there is no need to interpolate tweet["text"].
One problem here is that you're using quotes within quotes. Forgot to escape?
Another issue is that you're not printing anything. Merely returning the text in a loop does nothing and would always return the tweets object when the loop is complete.
So, here you go:
tweets = JSON.parse(response.body)
tweets.each do |tweet|
puts tweet["text"]
end
Update:
Well, I guess the quotes within quotes won't be a problem here as long as you use string interpolation. But it's still not the preferred way. I'd rather go with "#{tweet['text']}".
I can not figure out why NSDate continues to throw nil.
NSString * copyString = [[self.parseResults objectAtIndex:indexPath.row]objectForKey:#"date"];
NSDateFormatter *df = [[[NSDateFormatter alloc] init] autorelease];
[df setDateFormat:#"EEE, dd MMM yyyy HH:mm:ss zzz"];
NSDate *date = [df dateFromString:copyString];
NSLog(#"%#", copyString);
NSLog(#"%#",date);
Did I set the date format set properly?
Output from copyString
2014-01-24 11:17:25.893 Events[32755:70b] Wed, 31 Dec 1969 16:00:00
PST
2014-01-24 11:17:25.895 Events[32755:70b] Fri, 24 Jan 2014 20:00:00
PST
2014-01-24 11:17:25.896 Events[32755:70b] Sat, 25 Jan 2014 10:00:00
PST
2014-01-24 11:17:25.897 Events[32755:70b] Mon, 27 Jan 2014 10:00:00
PST
2014-01-24 11:17:25.899 Events[32755:70b] Mon, 27 Jan 2014 12:15:00
PST
2014-01-24 11:17:25.900 Events[32755:70b] Mon, 27 Jan 2014 19:00:00
PST
Output from date
2014-01-24 11:22:24.707 Events[32827:70b] (null)
2014-01-24 11:22:24.709 Events[32827:70b] (null)
2014-01-24 11:22:24.710 Events[32827:70b] (null)
2014-01-24 11:22:24.712 Events[32827:70b] (null)
2014-01-24 11:22:24.713 Events[32827:70b] (null)
2014-01-24 11:22:24.714 Events[32827:70b] (null)
I have multiple (more than 2) dataframes I would like to merge. They all share the same value column:
In [431]: [x.head() for x in data]
Out[431]:
[ AvgStatisticData
DateTime
2012-10-14 14:00:00 39.335996
2012-10-14 15:00:00 40.210110
2012-10-14 16:00:00 48.282816
2012-10-14 17:00:00 40.593039
2012-10-14 18:00:00 40.952014,
AvgStatisticData
DateTime
2012-10-14 14:00:00 47.854712
2012-10-14 15:00:00 55.041512
2012-10-14 16:00:00 55.488026
2012-10-14 17:00:00 51.688483
2012-10-14 18:00:00 57.916672,
AvgStatisticData
DateTime
2012-10-14 14:00:00 54.171233
2012-10-14 15:00:00 48.718387
2012-10-14 16:00:00 59.978616
2012-10-14 17:00:00 50.984514
2012-10-14 18:00:00 54.924745,
AvgStatisticData
DateTime
2012-10-14 14:00:00 65.813114
2012-10-14 15:00:00 71.397868
2012-10-14 16:00:00 76.213973
2012-10-14 17:00:00 72.729002
2012-10-14 18:00:00 73.196415,
....etc
I read that join can handle multiple dataframes, however I get:
In [432]: data[0].join(data[1:])
...
Exception: Indexes have overlapping values: ['AvgStatisticData']
I have tried passing rsuffix=["%i" % (i) for i in range(len(data))] to join and still get the same error. I can workaround this by building my data list in a way where the column names don't overlap, but maybe there is a better way?
In [65]: pd.concat(data, axis=1)
Out[65]:
AvgStatisticData AvgStatisticData AvgStatisticData AvgStatisticData
2012-10-14 14:00:00 39.335996 47.854712 54.171233 65.813114
2012-10-14 15:00:00 40.210110 55.041512 48.718387 71.397868
2012-10-14 16:00:00 48.282816 55.488026 59.978616 76.213973
2012-10-14 17:00:00 40.593039 51.688483 50.984514 72.729002
2012-10-14 18:00:00 40.952014 57.916672 54.924745 73.196415
I would try pandas.merge using the suffixes= option.
import pandas as pd
import datetime as dt
df_1 = pd.DataFrame({'x' : [dt.datetime(2012,10,21) + dt.timedelta(n) for n in range(10)], 'y' : range(10)})
df_2 = pd.DataFrame({'x' : [dt.datetime(2012,10,21) + dt.timedelta(n) for n in range(10)], 'y' : range(10)})
df = pd.merge(df_1, df_2, on='x', suffixes=['_1', '_2'])
I am interested to see if the experts have a more algorithmic approach to merge a list of data frames.