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;
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
here is my df2
desired output:
But when i apply this piece of code:
df2['X']=df1['X']
I got this result:
python python-3.x pandas
|
show 3 more comments
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
here is my df2
desired output:
But when i apply this piece of code:
df2['X']=df1['X']
I got this result:
python python-3.x pandas
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
|
show 3 more comments
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
here is my df2
desired output:
But when i apply this piece of code:
df2['X']=df1['X']
I got this result:
python python-3.x pandas
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
here is my df2
desired output:
But when i apply this piece of code:
df2['X']=df1['X']
I got this result:
python python-3.x pandas
python python-3.x pandas
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
|
show 3 more comments
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
|
show 3 more comments
1 Answer
1
active
oldest
votes
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)
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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)
add a comment |
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)
add a comment |
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)
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)
answered Mar 26 at 3:15
NickelNickel
1398 bronze badges
1398 bronze badges
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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