Posts: 48
Threads: 17
Joined: Oct 2019
Hi,
I have already converted the column x (see picture) into float64 but the output is really "weird" specially on excel but with Pandas it still saves many numbers after the dot. How can I manage to have just 2 numbers after the dot?. Thks
# Excel
-10.949.600.833.333.300
-21.294.745.833.333.300
-21.679.851.666.666.600
-10.070.619.666.666.600
-216.481.025
-14.975.645.666.666.600
-19.041.302.499.999.900
-14.257.553.333.333.300
-15.648.158.333.333.300
####
# Pandas
-10949.600833
-21294.745833
-21679.851667
-100706.196667
-21648.102500
-149756.456667
-19041.302500
-14257.553333
-15648.158333
Posts: 2,022
Threads: 9
Joined: May 2017
Without code, it's a guessing game.
Posts: 48
Threads: 17
Joined: Oct 2019
(Dec-09-2019, 07:28 AM)DeaD_EyE Wrote: Without code, it's a guessing game. Hi,
I don't think code will be needed here (correct em if I'm wrong, cause there is a lot of steps) ... I read the file with Pandas, converted the column into float and did some operations on the column and now I have this output.
Posts: 1,936
Threads: 8
Joined: Jun 2018
(Dec-09-2019, 07:38 AM)karlito Wrote: I don't think code will be needed here (correct em if I'm wrong, cause there is a lot of steps) ... I read the file with Pandas, converted the column into float and did some operations on the column and now I have this output.
So you read file which formatting we don't know, you converted it into float in a way we don't know, you performed some operations on floats we know nothing about and now you want to know why you have this output......
Maybe there are some graduates of Hogwarts School of Witchcraft and Wizardry who are able to answer this kind of question. I am not graduate of said school (and I see that DeaD_EyE is neither)
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Posts: 48
Threads: 17
Joined: Oct 2019
(Dec-09-2019, 02:00 PM)perfringo Wrote: (Dec-09-2019, 07:38 AM)karlito Wrote: I don't think code will be needed here (correct em if I'm wrong, cause there is a lot of steps) ... I read the file with Pandas, converted the column into float and did some operations on the column and now I have this output.
So you read file which formatting we don't know, you converted it into float in a way we don't know, you performed some operations on floats we know nothing about and now you want to know why you have this output......
Maybe there are some graduates of Hogwarts School of Witchcraft and Wizardry who are able to answer this kind of question. I am not graduate of said school (and I see that DeaD_EyE is neither)
Hi,
sorry guys ... I think I was wrong. so how can I edit my post or should post a new thread?
Posts: 48
Threads: 17
Joined: Oct 2019
(Dec-09-2019, 07:28 AM)DeaD_EyE Wrote: Without code, it's a guessing game. Hi,
I've posted an edited Thread about this issue. please follow the link if you want to help.
Posts: 50
Threads: 2
Joined: Nov 2019
try if round helps here,
source:trim_numbers.csv
a
-10949.600833
-21294.745833
-21679.851667
-100706.196667
-21648.102500
-149756.456667
-19041.302500
-14257.553333
-15648.158333
import pandas as pd
test = pd.read_csv('trim_numbers.csv', sep=",", index_col=False)
blankIndex=[''] * len(test)
test.index=blankIndex
test.columns = test.columns.str.lower()
'''
print(test.astype(float))
print(test.astype(int))
print(((test.astype(int)-test.astype(float))*100).astype(int)/100)
print(test.astype(int)-((test.astype(int)-test.astype(float))*100).astype(int)/100)
'''
print(test['a'].dtype)
print('---------------')
print(test['a'])
test['a']=test['a'].round(2)
print(test['a']) Best Regards,
Sandeep
GANGA SANDEEP KUMAR
Posts: 48
Threads: 17
Joined: Oct 2019
(Dec-12-2019, 08:44 AM)sandeep_ganga Wrote: try if round helps here,
source:trim_numbers.csv
a
-10949.600833
-21294.745833
-21679.851667
-100706.196667
-21648.102500
-149756.456667
-19041.302500
-14257.553333
-15648.158333
import pandas as pd
test = pd.read_csv('trim_numbers.csv', sep=",", index_col=False)
blankIndex=[''] * len(test)
test.index=blankIndex
test.columns = test.columns.str.lower()
'''
print(test.astype(float))
print(test.astype(int))
print(((test.astype(int)-test.astype(float))*100).astype(int)/100)
print(test.astype(int)-((test.astype(int)-test.astype(float))*100).astype(int)/100)
'''
print(test['a'].dtype)
print('---------------')
print(test['a'])
test['a']=test['a'].round(2)
print(test['a']) Best Regards,
Sandeep
GANGA SANDEEP KUMAR
Thanks Sandeep,
it does help but I still have these format
Posts: 1,936
Threads: 8
Joined: Jun 2018
Isn’t it somehow cell formatting issue? 30.12 and 6.96? Other numbers seem to be too large for displaying as date.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Posts: 48
Threads: 17
Joined: Oct 2019
(Dec-12-2019, 02:07 PM)perfringo Wrote: Isn’t it somehow cell formatting issue? 30.12 and 6.96? Other numbers seem to be too large for displaying as date.
You mean in Excel?
|