我正在尝试使用'since'
和从我管理的Instagram业务资料中检索上个月的媒体帖子'until'
,但由于API返回的帖子超出了我选择的时间范围,因此它似乎无法正常工作。
我正在使用以下字符串来调用API:
business_profile_id/media?fields=timestamp&since=2018-04-01&until=2018-04-30
Run Code Online (Sandbox Code Playgroud)
而Python片段就是这个(使用来自facebook-python-sdk 的相同初始化脚本)
import facebook
graph = facebook.GraphAPI(access_token)
profile = graph.get_object(user)
posts = graph.get_connections(profile['id'], 'media?fields=caption,permalink,timestamp&since=2018-04-01&until=2018-04-30')
Run Code Online (Sandbox Code Playgroud)
get.connections在哪里
def get_connections(self, id, connection_name, **args):
"""Fetches the connections for given object."""
return self.request(
"{0}/{1}/{2}".format(self.version, id, connection_name), args)
Run Code Online (Sandbox Code Playgroud)
和请求是
def request(
self, path, args=None, post_args=None, files=None, method=None):
"""Fetches the given path in the Graph API.
We translate args to a valid query string. If post_args is
given, we send a POST request to the given path with …
Run Code Online (Sandbox Code Playgroud) python facebook-graph-api python-3.x instagram instagram-api
我正在尝试获取数据帧八列之间每个可能组合的计数(所有行值为1)。基本上,我需要了解不同重叠存在多少次。
我试图用它itertools.product
来获得所有组合,但似乎不起作用。
import pandas as pd
import numpy as np
import itertools
df = pd.read_excel('filename.xlsx')
df.head(15)
a b c d e f g h
0 1 0 0 0 0 1 0 0
1 1 0 0 0 0 0 0 0
2 1 0 1 1 1 1 1 1
3 1 0 1 1 0 1 1 1
4 1 0 0 0 0 0 0 0
5 0 1 0 0 1 1 1 1 …
Run Code Online (Sandbox Code Playgroud) 我有这个数据框。
a b
0 NaN 2
1 2.0 4
2 NaN 7
Run Code Online (Sandbox Code Playgroud)
我正在尝试创建一个新列,方法是检查“a”列中的值类型并相应地分配一个新标签。结果应如下所示:
a b c
0 NaN 2 incomplete
1 2.0 4 complete
2 NaN 7 incomplete
Run Code Online (Sandbox Code Playgroud)
代码是:
if data_frame['a'].isna() == True:
data_frame['c'] = 'incomplete'
else:
data_frame['c'] = 'complete'
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用简单的 if / else 语句,但出现此错误:
*** SyntaxError: unexpected EOF while parsing
Run Code Online (Sandbox Code Playgroud)
有人可以提出解决方案吗?
非常感谢