When trying to add one dataframe column to other dataframe its giving NAnConvert bytes to a string?How do I sort a dictionary by value?Selecting multiple columns in a pandas dataframeHow can I replace all the NaN values with Zero's in a column of a pandas dataframeDelete column from pandas DataFrameSet value for particular cell in pandas DataFrame using index“Large data” work flows using pandasHow to iterate over rows in a DataFrame in Pandas?Select rows from a DataFrame based on values in a column in pandasWhy is “1000000000000000 in range(1000000000000001)” so fast in Python 3?

Is a request to book a business flight ticket for a graduate student an unreasonable one?

How do you glue a text to a point?

Why are all my yellow 2V/20mA LEDs burning out with 330k Ohm resistor?

Keep milk (or milk alternative) for a day without a fridge

How can I effectively communicate to recruiters that a phone call is not possible?

Why do people keep referring to Leia as Princess Leia, even after the destruction of Alderaan?

As the Dungeon Master, how do I handle a player that insists on a specific class when I already know that choice will cause issues?

What explains 9 speed cassettes price differences?

Is the genetic term "polycistronic" still used in modern biology?

What is the job of the acoustic cavities inside the main combustion chamber?

Simple interepretation problem regarding Polynomial Hierarchy?

How can one write good dialogue in a story without sounding wooden?

When casting Eldritch Blast with the Agonizing Blast eldritch invocation, what do I add to my damage roll?

Are randomly-generated passwords starting with "a" less secure?

Optimization terminology: "Exact" v. "Approximate"

How would vampires avoid contracting diseases?

If your plane is out-of-control, why does military training instruct releasing the joystick to neutralize controls?

definition of "percentile"

The monorail explodes before I can get on it

Is "I do not want you to go nowhere" a case of "DOUBLE-NEGATIVES" as claimed by Grammarly?

US Civil War story: man hanged from a bridge

Sending less data than the TCP buffer could take

How to memorize multiple pieces?

Is anyone advocating the promotion of homosexuality in UK schools?



When trying to add one dataframe column to other dataframe its giving NAn


Convert bytes to a string?How do I sort a dictionary by value?Selecting multiple columns in a pandas dataframeHow can I replace all the NaN values with Zero's in a column of a pandas dataframeDelete column from pandas DataFrameSet value for particular cell in pandas DataFrame using index“Large data” work flows using pandasHow to iterate over rows in a DataFrame in Pandas?Select rows from a DataFrame based on values in a column in pandasWhy is “1000000000000000 in range(1000000000000001)” so fast in Python 3?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am trying to add one column from df1 to df2 but i got NAn , but in real for this column in df1 have value.



here is my df1



enter image description here



here is my df2



enter image description here



desired output:



enter image description here



But when i apply this piece of code:



df2['X']=df1['X']


I got this result:



enter image description here










share|improve this question



















  • 1





    index different , try df2['X']=df1['X'].values

    – WeNYoBen
    Mar 26 at 2:41






  • 1





    @Wen-Ben , Thanks ,index was not same after adding .values problem solved

    – Nickel
    Mar 26 at 2:46











  • let me write a answer about it

    – WeNYoBen
    Mar 26 at 2:48











  • ok , and one more thing , if X in real is NAn then it will not give error ?

    – Nickel
    Mar 26 at 2:49











  • It will not raise error

    – WeNYoBen
    Mar 26 at 2:50

















0















I am trying to add one column from df1 to df2 but i got NAn , but in real for this column in df1 have value.



here is my df1



enter image description here



here is my df2



enter image description here



desired output:



enter image description here



But when i apply this piece of code:



df2['X']=df1['X']


I got this result:



enter image description here










share|improve this question



















  • 1





    index different , try df2['X']=df1['X'].values

    – WeNYoBen
    Mar 26 at 2:41






  • 1





    @Wen-Ben , Thanks ,index was not same after adding .values problem solved

    – Nickel
    Mar 26 at 2:46











  • let me write a answer about it

    – WeNYoBen
    Mar 26 at 2:48











  • ok , and one more thing , if X in real is NAn then it will not give error ?

    – Nickel
    Mar 26 at 2:49











  • It will not raise error

    – WeNYoBen
    Mar 26 at 2:50













0












0








0








I am trying to add one column from df1 to df2 but i got NAn , but in real for this column in df1 have value.



here is my df1



enter image description here



here is my df2



enter image description here



desired output:



enter image description here



But when i apply this piece of code:



df2['X']=df1['X']


I got this result:



enter image description here










share|improve this question
















I am trying to add one column from df1 to df2 but i got NAn , but in real for this column in df1 have value.



here is my df1



enter image description here



here is my df2



enter image description here



desired output:



enter image description here



But when i apply this piece of code:



df2['X']=df1['X']


I got this result:



enter image description here







python python-3.x pandas






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 26 at 2:41









rafaelc

31.2k8 gold badges32 silver badges55 bronze badges




31.2k8 gold badges32 silver badges55 bronze badges










asked Mar 26 at 2:38









NickelNickel

1398 bronze badges




1398 bronze badges







  • 1





    index different , try df2['X']=df1['X'].values

    – WeNYoBen
    Mar 26 at 2:41






  • 1





    @Wen-Ben , Thanks ,index was not same after adding .values problem solved

    – Nickel
    Mar 26 at 2:46











  • let me write a answer about it

    – WeNYoBen
    Mar 26 at 2:48











  • ok , and one more thing , if X in real is NAn then it will not give error ?

    – Nickel
    Mar 26 at 2:49











  • It will not raise error

    – WeNYoBen
    Mar 26 at 2:50












  • 1





    index different , try df2['X']=df1['X'].values

    – WeNYoBen
    Mar 26 at 2:41






  • 1





    @Wen-Ben , Thanks ,index was not same after adding .values problem solved

    – Nickel
    Mar 26 at 2:46











  • let me write a answer about it

    – WeNYoBen
    Mar 26 at 2:48











  • ok , and one more thing , if X in real is NAn then it will not give error ?

    – Nickel
    Mar 26 at 2:49











  • It will not raise error

    – WeNYoBen
    Mar 26 at 2:50







1




1





index different , try df2['X']=df1['X'].values

– WeNYoBen
Mar 26 at 2:41





index different , try df2['X']=df1['X'].values

– WeNYoBen
Mar 26 at 2:41




1




1





@Wen-Ben , Thanks ,index was not same after adding .values problem solved

– Nickel
Mar 26 at 2:46





@Wen-Ben , Thanks ,index was not same after adding .values problem solved

– Nickel
Mar 26 at 2:46













let me write a answer about it

– WeNYoBen
Mar 26 at 2:48





let me write a answer about it

– WeNYoBen
Mar 26 at 2:48













ok , and one more thing , if X in real is NAn then it will not give error ?

– Nickel
Mar 26 at 2:49





ok , and one more thing , if X in real is NAn then it will not give error ?

– Nickel
Mar 26 at 2:49













It will not raise error

– WeNYoBen
Mar 26 at 2:50





It will not raise error

– WeNYoBen
Mar 26 at 2:50












1 Answer
1






active

oldest

votes


















0














Problem solved:



Index was not same for df1 and df2 , due to index sensitivity of pandas occurred this problem , one memeber @wenben give suggestion to add .values it solved partial problem but when length for df1 and df2 not same .values will throw error.



Solution:



just reset index of df1 and df2 for making same index.



df1.reset_index(drop=True)
df2.reset_index(drop=True)





share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55349074%2fwhen-trying-to-add-one-dataframe-column-to-other-dataframe-its-giving-nan%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Problem solved:



    Index was not same for df1 and df2 , due to index sensitivity of pandas occurred this problem , one memeber @wenben give suggestion to add .values it solved partial problem but when length for df1 and df2 not same .values will throw error.



    Solution:



    just reset index of df1 and df2 for making same index.



    df1.reset_index(drop=True)
    df2.reset_index(drop=True)





    share|improve this answer



























      0














      Problem solved:



      Index was not same for df1 and df2 , due to index sensitivity of pandas occurred this problem , one memeber @wenben give suggestion to add .values it solved partial problem but when length for df1 and df2 not same .values will throw error.



      Solution:



      just reset index of df1 and df2 for making same index.



      df1.reset_index(drop=True)
      df2.reset_index(drop=True)





      share|improve this answer

























        0












        0








        0







        Problem solved:



        Index was not same for df1 and df2 , due to index sensitivity of pandas occurred this problem , one memeber @wenben give suggestion to add .values it solved partial problem but when length for df1 and df2 not same .values will throw error.



        Solution:



        just reset index of df1 and df2 for making same index.



        df1.reset_index(drop=True)
        df2.reset_index(drop=True)





        share|improve this answer













        Problem solved:



        Index was not same for df1 and df2 , due to index sensitivity of pandas occurred this problem , one memeber @wenben give suggestion to add .values it solved partial problem but when length for df1 and df2 not same .values will throw error.



        Solution:



        just reset index of df1 and df2 for making same index.



        df1.reset_index(drop=True)
        df2.reset_index(drop=True)






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 26 at 3:15









        NickelNickel

        1398 bronze badges




        1398 bronze badges


















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55349074%2fwhen-trying-to-add-one-dataframe-column-to-other-dataframe-its-giving-nan%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현