How to convert scientific notation stored as string to int in pandas dataframe?How do I parse a string to a float or int?Converting string into datetimeConvert bytes to a string?Converting integer to string?Selecting multiple columns in a pandas dataframeAdding new column to existing DataFrame in Python pandasDelete column from pandas DataFrameHow to iterate over rows in a DataFrame in Pandas?Select rows from a DataFrame based on values in a column in pandasGet list from pandas DataFrame column headers

Is it unusual for a math department not to have a mail/web server?

What was the point of "Substance"?

Stolen MacBook should I worry about my data?

Why is explainability not one of the criteria for publication?

Does trying to charm an uncharmable creature cost a spell slot?

Pen test results for web application include a file from a forbidden directory that is not even used or referenced

Did ancient peoples ever hide their treasure behind puzzles?

Why is there not a willingness from the world to step in between Pakistan and India?

Is the internet in Madagascar faster than in UK?

Force SQL Server to use fragmented indexes?

Can I use coax outlets for cable modem?

Commercial company wants me to list all prior "inventions", give up everything not listed

How to say "I only speak one which is English." in French?

If I said I had $100 when asked, but I actually had $200, would I be lying by omission?

Was a star-crossed lover

Dotted background on a flowchart

Are strlen optimizations really needed in glibc?

Half filled water bottle

Fantasy Macro Economics: What would Merfolk Trade?

Talk interpreter

To what extent should we fear giving offense?

How do I insert two edge loops equally spaced from the edges?

Counting the number of strings starting with "t" and containing 2 vowels and 2 consonants

Shift lens vs move body?



How to convert scientific notation stored as string to int in pandas dataframe?


How do I parse a string to a float or int?Converting string into datetimeConvert bytes to a string?Converting integer to string?Selecting multiple columns in a pandas dataframeAdding new column to existing DataFrame in Python pandasDelete column from pandas DataFrameHow to iterate over rows in a DataFrame in Pandas?Select rows from a DataFrame based on values in a column in pandasGet list from pandas DataFrame column headers






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








1















I have a column in a dataframe in pandas that is storing scientific notations as strings. I want to convert them strings to integers. But i am running into an issue that is best described by the code snippet below



Expected behavior:



print(int(float('9.01E+26')))
output:
901000000000000035886465024


Behaviour i am getting:



a = pd.Series('a':'9.01E+26')
print(a.astype(float).astype(int))
output:
a -9223372036854775808
dtype: int64


How do i go about achieving the expected behavior?










share|improve this question
























  • Interesting. I assume this is on Windows (edit: nevermind, you would have got dtype: int32 if it was). The default int type used by numpy is 32 bit on Windows, but indeed this overflows np.int64 too. It's not clear how to get python int behaviour that doesn't overflow

    – roganjosh
    Mar 27 at 20:40












  • In fact, I'm suspecting that you simply cannot work with integers of this size in numpy. You'd either need floats or work with python list comprehensions instead. Could be wrong, though.

    – roganjosh
    Mar 27 at 20:45












  • .apply would be the way to go then i guess?

    – MiloMinderbinder
    Mar 27 at 20:46











  • That will give you OverflowError: int too big to convert. There must be some interim dtype going from np.float to a regular Python int that simply blocks the conversion

    – roganjosh
    Mar 27 at 20:48











  • ohh that so? i was thinking that since int(float('9.01E+26')) works... .apply would work too

    – MiloMinderbinder
    Mar 27 at 20:49

















1















I have a column in a dataframe in pandas that is storing scientific notations as strings. I want to convert them strings to integers. But i am running into an issue that is best described by the code snippet below



Expected behavior:



print(int(float('9.01E+26')))
output:
901000000000000035886465024


Behaviour i am getting:



a = pd.Series('a':'9.01E+26')
print(a.astype(float).astype(int))
output:
a -9223372036854775808
dtype: int64


How do i go about achieving the expected behavior?










share|improve this question
























  • Interesting. I assume this is on Windows (edit: nevermind, you would have got dtype: int32 if it was). The default int type used by numpy is 32 bit on Windows, but indeed this overflows np.int64 too. It's not clear how to get python int behaviour that doesn't overflow

    – roganjosh
    Mar 27 at 20:40












  • In fact, I'm suspecting that you simply cannot work with integers of this size in numpy. You'd either need floats or work with python list comprehensions instead. Could be wrong, though.

    – roganjosh
    Mar 27 at 20:45












  • .apply would be the way to go then i guess?

    – MiloMinderbinder
    Mar 27 at 20:46











  • That will give you OverflowError: int too big to convert. There must be some interim dtype going from np.float to a regular Python int that simply blocks the conversion

    – roganjosh
    Mar 27 at 20:48











  • ohh that so? i was thinking that since int(float('9.01E+26')) works... .apply would work too

    – MiloMinderbinder
    Mar 27 at 20:49













1












1








1








I have a column in a dataframe in pandas that is storing scientific notations as strings. I want to convert them strings to integers. But i am running into an issue that is best described by the code snippet below



Expected behavior:



print(int(float('9.01E+26')))
output:
901000000000000035886465024


Behaviour i am getting:



a = pd.Series('a':'9.01E+26')
print(a.astype(float).astype(int))
output:
a -9223372036854775808
dtype: int64


How do i go about achieving the expected behavior?










share|improve this question














I have a column in a dataframe in pandas that is storing scientific notations as strings. I want to convert them strings to integers. But i am running into an issue that is best described by the code snippet below



Expected behavior:



print(int(float('9.01E+26')))
output:
901000000000000035886465024


Behaviour i am getting:



a = pd.Series('a':'9.01E+26')
print(a.astype(float).astype(int))
output:
a -9223372036854775808
dtype: int64


How do i go about achieving the expected behavior?







python pandas






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 27 at 20:37









MiloMinderbinderMiloMinderbinder

7887 silver badges16 bronze badges




7887 silver badges16 bronze badges















  • Interesting. I assume this is on Windows (edit: nevermind, you would have got dtype: int32 if it was). The default int type used by numpy is 32 bit on Windows, but indeed this overflows np.int64 too. It's not clear how to get python int behaviour that doesn't overflow

    – roganjosh
    Mar 27 at 20:40












  • In fact, I'm suspecting that you simply cannot work with integers of this size in numpy. You'd either need floats or work with python list comprehensions instead. Could be wrong, though.

    – roganjosh
    Mar 27 at 20:45












  • .apply would be the way to go then i guess?

    – MiloMinderbinder
    Mar 27 at 20:46











  • That will give you OverflowError: int too big to convert. There must be some interim dtype going from np.float to a regular Python int that simply blocks the conversion

    – roganjosh
    Mar 27 at 20:48











  • ohh that so? i was thinking that since int(float('9.01E+26')) works... .apply would work too

    – MiloMinderbinder
    Mar 27 at 20:49

















  • Interesting. I assume this is on Windows (edit: nevermind, you would have got dtype: int32 if it was). The default int type used by numpy is 32 bit on Windows, but indeed this overflows np.int64 too. It's not clear how to get python int behaviour that doesn't overflow

    – roganjosh
    Mar 27 at 20:40












  • In fact, I'm suspecting that you simply cannot work with integers of this size in numpy. You'd either need floats or work with python list comprehensions instead. Could be wrong, though.

    – roganjosh
    Mar 27 at 20:45












  • .apply would be the way to go then i guess?

    – MiloMinderbinder
    Mar 27 at 20:46











  • That will give you OverflowError: int too big to convert. There must be some interim dtype going from np.float to a regular Python int that simply blocks the conversion

    – roganjosh
    Mar 27 at 20:48











  • ohh that so? i was thinking that since int(float('9.01E+26')) works... .apply would work too

    – MiloMinderbinder
    Mar 27 at 20:49
















Interesting. I assume this is on Windows (edit: nevermind, you would have got dtype: int32 if it was). The default int type used by numpy is 32 bit on Windows, but indeed this overflows np.int64 too. It's not clear how to get python int behaviour that doesn't overflow

– roganjosh
Mar 27 at 20:40






Interesting. I assume this is on Windows (edit: nevermind, you would have got dtype: int32 if it was). The default int type used by numpy is 32 bit on Windows, but indeed this overflows np.int64 too. It's not clear how to get python int behaviour that doesn't overflow

– roganjosh
Mar 27 at 20:40














In fact, I'm suspecting that you simply cannot work with integers of this size in numpy. You'd either need floats or work with python list comprehensions instead. Could be wrong, though.

– roganjosh
Mar 27 at 20:45






In fact, I'm suspecting that you simply cannot work with integers of this size in numpy. You'd either need floats or work with python list comprehensions instead. Could be wrong, though.

– roganjosh
Mar 27 at 20:45














.apply would be the way to go then i guess?

– MiloMinderbinder
Mar 27 at 20:46





.apply would be the way to go then i guess?

– MiloMinderbinder
Mar 27 at 20:46













That will give you OverflowError: int too big to convert. There must be some interim dtype going from np.float to a regular Python int that simply blocks the conversion

– roganjosh
Mar 27 at 20:48





That will give you OverflowError: int too big to convert. There must be some interim dtype going from np.float to a regular Python int that simply blocks the conversion

– roganjosh
Mar 27 at 20:48













ohh that so? i was thinking that since int(float('9.01E+26')) works... .apply would work too

– MiloMinderbinder
Mar 27 at 20:49





ohh that so? i was thinking that since int(float('9.01E+26')) works... .apply would work too

– MiloMinderbinder
Mar 27 at 20:49












0






active

oldest

votes










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%2f55386043%2fhow-to-convert-scientific-notation-stored-as-string-to-int-in-pandas-dataframe%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using 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%2f55386043%2fhow-to-convert-scientific-notation-stored-as-string-to-int-in-pandas-dataframe%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권, 지리지 충청도 공주목 은진현