问题描述
fbLogin() {
this.fb.login(['public_profile','email'])
.then(res => {
if (res.status === 'connected') {
this.isLoggedIn = true;
console.log(res);
this.authService.handleFacebookCallback().subscribe(
res => {
console.log(res);
},err => {
console.log(err);
});
this.getUserDetail(res.authResponse.userID);
} else {
this.isLoggedIn = false;
}
})
.catch(e => console.log('Error logging into Facebook',e));
}
我希望输出是这样的
import pandas as pd,numpy as np
env_height = 9
env_width = 9
pixels = 40
action_1 = ['up','down','left','right']
action_2 = action_1.copy
actions = [action_1] + [action_2]
state_space = []
for x in range (0,(env_width * pixels),pixels):
for y in range (0,(env_height * pixels),pixels):
state_space += [[x,y]]
state = [str(s) for s in state_space]
q_table = pd.DataFrame(columns = actions,index=state)
print (q_table)
解决方法
请尝试在"up "
中的单词上添加空格(即action_2
),因为用这种方式您只是覆盖了action_1
中的列。
action_2 = [word + " " for word in action_1]
,
只需使用copy()
而不是copy
。或者,您可以简单地分配action_2 = action_1
。这不会替换原始列表。
然后拉平列表actions
env_height = 9
env_width = 9
pixels = 40
action_1 = ['up','down','left','right']
action_2 = action_1
actions = [action_1] + [action_2]
state_space = []
for x in range (0,(env_width * pixels),pixels):
for y in range (0,(env_height * pixels),pixels):
state_space += [[x,y]]
# flatten the list of lists
actions = [item for sublist in actions for item in sublist]
q_table = pd.DataFrame(columns = actions,index=state)
print(q_table)
up down left right up down left right
[0,0] NaN NaN NaN NaN NaN NaN NaN NaN
[0,40] NaN NaN NaN NaN NaN NaN NaN NaN