-1
I have a folder with about 480 CSV files, only they don’t have an index and I created another CSV file to be their index (there are 119 columns in the index) When I enter using df.append the file becomes 238 columns, ie fold. I tried everything to insert this index as the first row before reading the files, as I do to insert the lines below the title of their columns?
I tried that:
df1= pd.read_csv('/home/user/TCC/2015/index.csv')
df2= pd.read_csv('/home/user/TCC/2015/data.csv')
df1 = df1.append(df2)
I tried that way too:
result = pd.concat([df1, df2], axis=1).reindex(df_index.index)
If you can help, thank you.
I tried that but got the answer: Typeerror: set_index() takes from 2 to 6 positional Arguments but 119 Were Given
– Matheus Jarel
'index' in the new.set_index('index', inplace = True) command is a string. It looks like you have put an object with 119 entries in place. If you have any questions check the documentation to see how the method works: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.set_index.html Something else, your problem would be clearer if you showed a replicable example or made the files available
– Lucas
I tried the function here it creates new columns, I want to insert the values of a Dataframe (which has 119 columns) and I want another Dataframe to receive this data to be the index. As in the example: df1 = A B C D ------------------- df2 = 1 2 3 4 5 6 7 8 9 10 11 12 df1 + df2 = dfmerged dfmerged = A B C D 1 2 3 4 5 6 7 8
– Matheus Jarel