Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started