dataframe print column comma separated 1

dataframe print column comma separated

print("',\n'".join(df['col_name'].values.tolist()))

Here is what the above code is Doing:
1. We’re using the pandas library to read in the CSV file.
2. We’re using the .values.tolist() method to convert the values in the column to a list.
3. We’re using the .join() method to join the list together into a single string.
4. We’re using the .print() method to print the string.

Similar Posts