Issue
// I am trying to concatenate my 2 csv files into pandas data frame but I am not getting proper output 1st csv contains only 3 columns named ProductID ProductName ProductBrand and 2 nd csv contains this columns Price (INR) NumImages ID Description where instead of data I am getting Nan I am getting data in my 2nd csv only after data of my 1 st csv is getting finished I am new to this Any help would be highly appreciated I am sharing my code too
// output:
ProductID ProductName ProductBrand Gender Price (INR) NumImages ID Description PrimaryColor
10017413.0 DKNY Unisex Black DKNY NaN NaN NaN NaN NaN NaN
10016283.0 EthnoVogue Women EthnoVogue NaN NaN NaN NaN NaN NaN
// Python Code:
import pandas as pd
# merging two csv files
df = pd.concat(map(pd.read_csv, ['data1.csv', 'data2.csv']), ignore_index=True)
Solution
Add axis=1 as below.
df = pd.concat(map(pd.read_csv, ['a.csv', 'b.csv']), ignore_index=True, axis = 1)
Answered By - sp0392
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.