import pandas as pd
df = pd.DataFrame({"A":[1, 5, 5],
"B":[2, 6, 7],
"C":[3, 7, 5],
"D":[" "]*3})
print (df)
for e in range (3):
d= input(" put the number:")
df.at[e,'D']=d
print (df)
输出为:
A B C D
0 1 2 3
1 5 6 7
2 5 7 5
put the number:1
put the number:2
put the number:3
A B C D
0 1 2 3 1
1 5 6 7 2
2 5 7 5 3
示例的最终代码(基于注释):
def enter_new_column(df, name):
for e in range (df.shape[0]):
d= input(" put the number: ")
df.at[e,name]=d
enter_new_column(devis, "Quantité")
import pandas as pd
df = pd.DataFrame({"A":[1,5,5],"B":[2,6,7],"C":[3,7,5]})
def enter_new_column(df, name, print_column):
# loop over length of the rows
temp_arr = []
for i in range(df.shape[0]):
temp_arr.append(input(f"Put the Number for the value {df[print_column][i]}: "))
df[name] = temp_arr
enter_new_column(df=df, name="D", print_column="Intitulé_complet")
我希望这就是你要寻找的:
输出为:
示例的最终代码(基于注释):
我想我知道你在问什么,虽然我不知道
.interlupes()
是什么意思您想要做的是相对简单的,您想要捕获用户输入并将它们放置在数据帧中的某个位置。你没有弄清楚的是,你是如何捕捉到它们放在哪里的
在您的示例中,您可以这样做:
相关问题 更多 >
编程相关推荐