I've been trying to convert a pandas dataframe column of list elements to json and push it to snowflake as a variant but I'm stuck in 1st step.
I have a pandas dataframe with ID and conversation transcript which looks in this way.
Sample dataframe:
ID transcript
1 ['Joe([email protected]): Hey', 'Smoe([email protected]): Hey!! How are you doing?', 'Joe([email protected]): I'm doing good']
And, I have multiple rows(conversation transcripts with different ID) with same format
Expected dataframe:
ID transcript
1 {'Joe([email protected]): Hey', 'Smoe([email protected]): Hey!! How are you doing?', 'Joe([email protected]): I'm doing good'}
I tried to convert each individual object to json but list object has no attribute 'to_json'
df['transcript_json'] = df['transcript_json'].apply(lambda x: x.to_json())
I also tried converting the whole column into a json object which gave me a big string object but didn't get me any further where I want to go.
transcript_list = df['transcript'].to_json()
{"0":["Joe([email protected]): Hey", "Smoe([email protected]): Hey!! How are you doing?", "Joe([email protected]): I'm doing good"]}
I know I'm missing something small here. Any ideas on how to do it would be much appreciated.
['Joe([email protected]): Hey', 'Smoe([email protected]): Hey!! How are you doing?', 'Joe([email protected]): I'm doing good']