Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have two .csv files that I am using pandas library to read as df's in python. First files has just one column with 15

I have two .csv files that I am using pandas library to read as df's in python. First files has just one column with 15 rows that include title names. Second file has 20 columns and I want to rename the first 5 with my own created names and the last 15 columns using the 15 rows of the first file. I have already saved the first file as df1 in python. Please tell me how I can save the second file as df2 while renaming the columns (I am using the name = code to rename the first 5 rows but I do not know how to incorporate a line of code that will rename the last 15 columns using df1). My current code to save df2 names all columns manually, whereas I want it to save only for first 5 names manually and then used df 1 to change the rest 15: df2 = pd.read_csv('location of .csv file', names=['col1', 'col2', ... 'col20''], encoding ='latin1', sep='\t'). Please tell me how to adjust this code to work how I want it to. FYI - the last 15 columns have Boolean values (i.e., return 0 if false and 1 if true)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Decisions Based On Data Analytics For Business Excellence

Authors: Bastian Weber

1st Edition

9358681683, 978-9358681680

More Books

Students also viewed these Databases questions

Question

4. The economic arguments for and against income inequality.

Answered: 1 week ago

Question

Explain the nature of human resource management.

Answered: 1 week ago

Question

Write a note on Quality circles.

Answered: 1 week ago

Question

Describe how to measure the quality of work life.

Answered: 1 week ago