w3resource logo
Python Exercises

Python Pandas: Display the specified data column wise

Python Pandas: DateFrame Exercise-1 with Solution

Write a Python program to display the following data column wise.

Sample data: {‘X’:[78,85,96,80,86], 'Y':[84,94,89,83,86],'Z':[86,97,96,72,83]}

Sample Solution :-

Python Code :

import pandas as pd
df = pd.DataFrame({'X':[78,85,96,80,86], 'Y':[84,94,89,83,86],'Z':[86,97,96,72,83]});
print(df)

Sample Output:

    X   Y   Z                                                          
0  78  84  86                                                          
1  85  94  97                                                          
2  96  89  96                                                          
3  80  83  72                                                          
4  86  86  83                                       

Python Code Editor:

import pandas as pd
df = pd.DataFrame({'X':[78,85,96,80,86], 'Y':[84,94,89,83,86],'Z':[86,97,96,72,83]});
print(df)

Improve this sample solution and post your code through Disqus