Package: a-pandas-ex-to-tuple
Converts pandas DataFrames/Series into Iterator[tuple]pipinstalla-pandas-ex-to-tuplefroma_pandas_ex_to_tupleimportpd_add_tuplespd_add_tuples()importpandasaspdfrompprintimportpprintdf=pd.read_csv("https://github.com/pandas-dev/pandas/raw/main/doc/data/titanic.csv")df=df[:5]# DataFramet1=tuple(df.ds_to_tuples(index=False,columns=True))t2=tuple(df.ds_to_tuples(index=True,columns=True))t3=tuple(df.ds_to_tuples(index=True,columns=False))t4=tuple(df.ds_to_tuples(index=False,columns=False))pprint(t1)pprint(t2)pprint(t3)pprint(t4)# Seriest11=tuple(df.Name.ds_to_tuples(index=False,columns=True))t21=tuple(df.Name.ds_to_tuples(index=True,columns=True))t31=tuple(df.Name.ds_to_tuples(index=True,columns=False))t41=tuple(df.Name.ds_to_tuples(index=False,columns=False))pprint(t11)pprint(t21)pprint(t31)pprint(t41)(('PassengerId','Survived','Pclass','Name','Sex','Age','SibSp','Parch','Ticket','Fare','Cabin','Embarked'),(1,0,3,'Braund, Mr. Owen Harris','male',22.0,1,0,'A/5 21171',7.25,nan,'S'),(2,1,1,'Cumings, Mrs. John Bradley (Florence Briggs Thayer)','female',38.0,1,0,'PC 17599',71.2833,'C85','C'),(3,1,3,'Heikkinen, Miss. Laina','female',26.0,0,0,'STON/O2. 3101282',7.925,nan,'S'),(4,1,1,'Futrelle, Mrs. Jacques Heath (Lily May Peel)','female',35.0,1,0,'113803',53.1,'C123','S'),(5,0,3,'Allen, Mr. William Henry','male',35.0,0,0,'373450',8.05,nan,'S'))(('index','PassengerId','Survived','Pclass','Name','Sex','Age','SibSp','Parch','Ticket','Fare','Cabin','Embarked'),(0,1,0,3,'Braund, Mr. Owen Harris','male',22.0,1,0,'A/5 21171',7.25,nan,'S'),(1,2,1,1,'Cumings, Mrs. John Bradley (Florence Briggs Thayer)','female',38.0,1,0,'PC 17599',71.2833,'C85','C'),(2,3,1,3,'Heikkinen, Miss. Laina','female',26.0,0,0,'STON/O2. 3101282',7.925,nan,'S'),(3,4,1,1,'Futrelle, Mrs. Jacques Heath (Lily May Peel)','female',35.0,1,0,'113803',53.1,'C123','S'),(4,5,0,3,'Allen, Mr. William Henry','male',35.0,0,0,'373450',8.05,nan,'S'))((0,1,0,3,'Braund, Mr. Owen Harris','male',22.0,1,0,'A/5 21171',7.25,nan,'S'),(1,2,1,1,'Cumings, Mrs. John Bradley (Florence Briggs Thayer)','female',38.0,1,0,'PC 17599',71.2833,'C85','C'),(2,3,1,3,'Heikkinen, Miss. Laina','female',26.0,0,0,'STON/O2. 3101282',7.925,nan,'S'),(3,4,1,1,'Futrelle, Mrs. Jacques Heath (Lily May Peel)','female',35.0,1,0,'113803',53.1,'C123','S'),(4,5,0,3,'Allen, Mr. William Henry','male',35.0,0,0,'373450',8.05,nan,'S'))((1,0,3,'Braund, Mr. Owen Harris','male',22.0,1,0,'A/5 21171',7.25,nan,'S'),(2,1,1,'Cumings, Mrs. John Bradley (Florence Briggs Thayer)','female',38.0,1,0,'PC 17599',71.2833,'C85','C'),(3,1,3,'Heikkinen, Miss. Laina','female',26.0,0,0,'STON/O2. 3101282',7.925,nan,'S'),(4,1,1,'Futrelle, Mrs. Jacques Heath (Lily May Peel)','female',35.0,1,0,'113803',53.1,'C123','S'),(5,0,3,'Allen, Mr. William Henry','male',35.0,0,0,'373450',8.05,nan,'S'))(('Name',),('Braund, Mr. Owen Harris',),('Cumings, Mrs. John Bradley (Florence Briggs Thayer)',),('Heikkinen, Miss. Laina',),('Futrelle, Mrs. Jacques Heath (Lily May Peel)',),('Allen, Mr. William Henry',))(('index','Name'),(0,'Braund, Mr. Owen Harris'),(1,'Cumings, Mrs. John Bradley (Florence Briggs Thayer)'),(2,'Heikkinen, Miss. Laina'),(3,'Futrelle, Mrs. Jacques Heath (Lily May Peel)'),(4,'Allen, Mr. William Henry'))((0,'Braund, Mr. Owen Harris'),(1,'Cumings, Mrs. John Bradley (Florence Briggs Thayer)'),(2,'Heikkinen, Miss. Laina'),(3,'Futrelle, Mrs. Jacques Heath (Lily May Peel)'),(4,'Allen, Mr. William Henry'))(('Braund, Mr. Owen Harris',),('Cumings, Mrs. John Bradley (Florence Briggs Thayer)',),('Heikkinen, Miss. Laina',),('Futrelle, Mrs. Jacques Heath (Lily May Peel)',),('Allen, Mr. William Henry',))