如何解决熊猫中的重复列
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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。