Skip to main content

Posts

Showing posts with the label 7. Create a dataframe and iterate them over rows.

ads1

7. Create a dataframe and iterate them over rows.

  7. Create a dataframe and iterate them over rows. Solution :-  data = [["Virat",55,66,31],["Rohit",88,66,43],[          "Hardik",99,101,68]] players = pd.DataFrame(data,           columns = ["Name","Match-1","Match-2","Match-3"]) print("Iterating by rows:") print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") for index, row in players.iterrows():     print(index, row.values) print("Iterating by columns:") print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") for index, row in players.iterrows():     print(index, row["Name"],row["Match-1"],           row["Match-2"],row["Match-3"])

ads2