Every string is changing to NaN while assigning a Key value pair in Dict


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]})

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]])):
result = json.dumps(out, indent = 4)

When i print the result, every value tagged to key ‘response’ is updated as NaN.

Data responses contain both NaN and Strings.


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.

people found this article helpful. What about you?

Exit mobile version