Python Forum
pandas convert to tuple & float to float64
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pandas convert to tuple & float to float64
#3
Hi snippsat,
Thanks for your reply.

when I run:

    newfour_2['GDPDiff']=np.subtract(newfour['2015'],newfour['2006'])
    newfour_2['GDPDiff'].astype(np.float64)
    return type(newfour_2.iloc[0])
the output is:float not float64.


For case 2.
when I run:

    sixlist=df.to_records().tolist() 
    return type(sixlist) #newtwo["% Renewable"].max()
answer_six()
the output is:list and not tuple so tolist()does not seem to do the trick.

And to_tuple() or tuple() does not exist: AttributeError: recarray has no attribute to_tuple/tuple

Even tuple() has the type numpy.recarray

    purchase_1 = tuple({'Country': 'Brazil',
                        '% Renewable': '69.648030000000006'})

    df = pd.DataFrame([purchase_1])

                                       
    #only_gold = df.where(df['Gold']== 5)
    sixlist=df.to_records()
    return type(sixlist) #newtwo["% Renewable"].max()
Reply


Messages In This Thread
RE: pandas convert to tuple & float to float64 - by metalray - Feb-27-2017, 08:55 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How can I convert specific rows from excel to pandas dataframe? mcva 1 1,864 Apr-20-2020, 09:14 AM
Last Post: pyzyx3qwerty
  Error could not convert string to float: deadendstreet 4 5,535 Oct-02-2019, 05:49 PM
Last Post: ichabod801
  ValueError: could not convert string to float: 'Pencil' Balakay97 3 6,013 Mar-08-2018, 07:30 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

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