Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SOURCE CODE:
- *Please follow the comments to better understand the code.
- **Please look at the Screenshot below and use this code to copy-paste.
- ***The code in the below screenshot is neatly indented for better understanding.
- import pandas as pd
- pd.set_option('display.max_columns', None)
- # read filename
- filename = input('Enter a file name: ')
- # open file
- with open(filename) as file:
- # Create a data frame
- df = pd.read_csv(file)
- # get only the columns required
- sub_df = df[['mpg', 'horsepower', 'model_year', 'name']]
- # print the sub data frame
- print('Last 5 rows of columns mpg, horsepower, model_year, and name:')
- print(sub_df.tail(5))
- http://prntscr.com/pyrsfs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement