I want an organized output
for ind in df.index:
print(df['Name'][ind], df['Stream'][ind].rjust(15," "))
I did this but I'm not getting the expected output
import pandas as pd
data = {'Name': ['Ankit', 'Amit', 'Aishwarya', 'Priyanka'],
'Age': [21, 19, 20, 18],
'Stream': ['Math', 'Commerce', 'Arts', 'Biology'],
'Percentage': [88, 92, 95, 70]}
df = pd.DataFrame(data, columns = ['Name', 'Age', 'Stream', 'Percentage'])
print("Given Dataframe :\n", df)
print("\nIterating over rows using index attribute :\n")
for ind in df.index:
print(df['Name'][ind], df['Stream'][ind])
Output:
Ankit Math
Amit Commerce
Aishwarya Arts
Priyanka Biology
Expected output:
Ankit Math
Amit Commerce
Aishwarya Arts
Priyanka Biology
I want my output like expected output i have tried with right alignment but not getting the expected output; how can I get this?