So I have this function:
def get_tag(word):
df1 = pd.DataFrame(0, index=[1], columns=cols)
df2 = df1
df1 = get_freqs(word)
L = df1.loc[1, :].idxmax()
if df1.loc[1, L] > 0:
df2.loc[1, L] = 1
return df2
which returns a Series, as I expect it to :
wf.get_tag("email")
City CompanyName Country ... MiddleName State Street
1 0 0 0 ... 1 0 0
[1 rows x 10 columns]
yet if I use it and assign the result to a cell of another series the value is nan:
word_df = pd.DataFrame(columns=WORD_FEATS)
...
word_df.loc[0, "TAGS"] = wf.get_tag(word)
By printing:
for l in list(word_df):
print(l + ": " + str(word_df.loc[0, l]))
I get :
TAGS: nan
for any input.
Why does this happen?