3

This is weird. From the documentation I all ready read how to do concat and merge operations with pandas. Also I all ready know that concatenating to the right side can be done as follows:

df = pd.concat([df1, df2], axis=1)

The issue is that I generated the following dataframes:

In:

links = pd.DataFrame(links, columns=['link'])

So, I just want to concatenate the link dataframe column to intersection dataframe (note that link and intersection have 78 instances of length). Thus:

In:

full_table = pd.concat([lis_, lis_2], axis=1)

The problem is that as you can see in the above dataframe, it added some NaN values. Therefore, which is the correct way of concatenating links and intersection dataframes?.

tumbleweed
  • 4,624
  • 12
  • 50
  • 81

1 Answers1

2

Maybe your indexes don't match up. Try using the ignore_index parameter:

full_table = pd.concat([intersection, links], axis=1, ignore_index=True)
Alex
  • 12,078
  • 6
  • 64
  • 74
  • Your index is clearly the problem. Just compare the output of your link and intersection dataframes above (one index starts at 0 and the other starts at 1). Try resetting the indexes manually with `df.index = list(range(len(df)))` for each. – Alex Nov 23 '16 at 04:47