Python Forum
Concatenate/Join/Merge two Dataframes
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Concatenate/Join/Merge two Dataframes
#5
(Jan-21-2020, 11:04 AM)perfringo Wrote: Totally unclear for me what data you have and how you want to manipulate it.

Want to add column to existing dataframe?

>>> df = pd.DataFrame({'nums': range(5)})                            
>>> df                                                               
   nums
0     0
1     1
2     2
3     3
4     4
>>> df['chars'] = list('abcde')                                      
>>> df                                                               
   nums chars
0     0     a
1     1     b
2     2     c
3     3     d
4     4     e
>>> df['NaNs'] = np.nan                                              
>>> df                                                               
   nums chars  NaNs
0     0     a   NaN
1     1     b   NaN
2     2     c   NaN
3     3     d   NaN
4     4     e   NaN

Hi,

I have two Dataframes.
- test_df with 2 columns: date as index and night_cons (see image)
- pred_df with just a column "prediction" (see image)

I'm trying to merge both but when I do it, the final merged Dataframe gives NAN in the prediction column (see image please)

Hi,
I got it ... It was an index issue.
Thank you all.
Reply


Messages In This Thread
Concatenate/Join/Merge two Dataframes - by karlito - Jan-20-2020, 01:05 PM
RE: Concatenate/Join/Merge two Dataframes - by karlito - Jan-21-2020, 12:36 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Concatenate 3D arrays paul18fr 1 2,684 Apr-09-2021, 02:49 PM
Last Post: paul18fr
  Merging two DataFrames based on indexes from two other DataFrames lucinda_rigeitti 0 1,771 Jan-16-2020, 08:36 PM
Last Post: lucinda_rigeitti
  concatenate mcgrim 1 2,267 Mar-22-2019, 01:31 PM
Last Post: buran
  Why can't I merge pandas dataframes learnpython2018 2 7,741 Sep-23-2018, 05:53 PM
Last Post: learnpython2018

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020