0

This may sound convoluted, but I'm trying. If I'm not clear, please let me know and I will update this.

I have a data frame (Excel) made up of tweets and accompanying data sent by US congressmembers. One of these columns ("to") is composed of lists of strings (see image below).

enter image description here

I am trying to preserve these lists in this "to" column while saving the whole data frame as a CSV file, such that all these names are still recognized as a list of strings within the CSV file. The reason I need to save it in this format is that I'm using existing code to run some analyses on this data, and that code requires it in CSV format. The code I'm trying to run comes from this Github Repository project. In this code (see the measure.py document), the authors state I should be able to include a list of user strings in the from column (See image below -- I believe they mean the "to" not "from" column, but I've tried it both ways with the same result).

enter image description here

The code works with the CSV file if there is only one name in each cell of the "to" column, but it hasn't worked if there are multiple names/strings in the cell. I could be wrong, but it seems that the lists of strings confuse the code when saved as a CSV file. I have tried to get help from the github repository contributors, but with no response. Any help would be greatly appreciated.

3
  • Have you tried using pandas? Convert from excel to pandas stackoverflow.com/questions/44070938/… and then use df.to_csv? Commented Dec 7, 2021 at 19:45
  • @bonfab, I haven't used pandas (I'm not very familiar with python), but I tried to write the dataframe to a csv file in R. I was able to do that, but the code still didn't work. Do you think it might work better with pandas? Commented Dec 7, 2021 at 20:21
  • @Iwe pandas allows lists to be written to csv. They would look like "[a, b, c]" in the csv file. Commented Dec 7, 2021 at 21:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.