-2

I used the following code

import itertools
f = list(itertools.combinations(['Javad', 'love', 'python'], 2))
print (f)

An I got the following result:

[('Javad', 'love'), ('Javad', 'python'), ('love', 'python')]

I'm looking for a way to transfer them to a csv or excel file as follow:

enter image description here

Venkatesh Wadawadagi
  • 2,793
  • 21
  • 34

1 Answers1

0

It's easy, use pandas

import pandas as pd
df = pd.DataFrame(f)
df.to_csv('your_name.csv')

pandas convert your data container to a Dataframe, based on the structure of data. for example you can convert dictionaries to Dataframe and after that you can manipulate them or export them to csv, Excel and much more formats.

Mehdi
  • 1,260
  • 2
  • 16
  • 36