0

I am trying to import txt file data into a dataframe. This is the code I used to load the textiles data then join them together in a dataframe.

import pandas as 
n254_1=pd.read_csv('input_1.txt')
n254_2=pd.read_csv('input_2.txt')
daf=pd.DataFrame({'run1':[n254_1], 'run2':[n254_2]})
print("length of dataframe %i",len(daf))
print(daf)

The problem is that the resulting dataframe is not iterable. Morever, when I print the dataframe "daf", I get the following output:

enter image description here

JohanC
  • 71,591
  • 8
  • 33
  • 66
Muna Tageldin
  • 31
  • 1
  • 2
  • `pd.read_csv()` already returns a DataFrame, so `daf` is a DataFrame of DataFrames. I suspect this wasn't your intention. Are you trying to put two DataFrames together into one somehow? If so, what would you like the final result to look like? – Frodnar Jun 24 '22 at 14:34
  • ok. I am trying to join n254_1 and n254_2 into one dataframe. How can I do that? @Frodnar Thanks – Muna Tageldin Jun 24 '22 at 14:52
  • Read: https://stackoverflow.com/questions/53645882/pandas-merging-101/ – Vishnudev Krishnadas Jun 24 '22 at 16:18
  • check concat optionn to join df's verticaly or horisontaly – NoobVB Jun 25 '22 at 16:18

0 Answers0