Issue
This Content is from Stack Overflow. Question asked by vishnu mk
data_utterance = pd.read_csv("Ruby_test/utterance.csv")
data_responses = pd.read_csv("Ruby_test/responses.csv")
r,c = data_utterance.shape
r1,c1 = data_responses.shape
s_out = defaultdict(dict)
for i in range(0,r):
s_out.setdefault(data_utterance.iloc[i,0],[]).append({'query': data_utterance.iloc[i,1]})
#print(s_out)
out = defaultdict(dict)
for i in intent:
for j in locales:
out[i][j] = s_out[i]
for i in range(0,r1):
for j in range(0,len(out[data_responses.iloc[i,0]][data_responses.iloc[i,1]])):
out[data_responses.iloc[i,0]][data_responses.iloc[i,1]][j]['response']=data_responses.iloc[i,2]
result = json.dumps(out, indent = 4)
print(result)
When i print the result, every value tagged to key ‘response’ is updated as NaN.
Data responses contain both NaN and Strings.
Solution
This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.
This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.