How can I print a pandas table with converted values in python?

I am having trouble avoiding NAN values in my newest data table after I have converted the data types: Symbol, Exchange, and Date from object data types to float64 data types. If you look at my last printed data table, I only get NAN values and no readable data as I wish to. Does someone know what could be the issue here and how to fix it so that there is readable data showing instead? Thanks in advance!

import requests # For http request to https://marketstack.com
import pandas as pd # For pandas datatable
import numpy as np

# Api Key
params = {
    'access_key': '****************************'
}

# Request Api Key Data
api_result = requests.get('https://api.marketstack.com/v1/eod?access_key=************************&symbols=FB&interval=1min&sort=DESC&limit=1000', params)
api_response = api_result.json()

# Sorts the data into a table
df = pd.DataFrame(api_response['data'])
print(df)

# Exports and then imports csv data
df.to_csv('Test_Sample.csv', index=False)
dataframe = pd.read_csv('Test_Sample.csv', header=0)

#Reverse data table
dataframe2 = dataframe.iloc[::-1]
print(dataframe2)

#Convert string to floats
dataframe2['symbol']=pd.to_numeric(dataframe2['symbol'], errors='coerce')
dataframe2['exchange']=pd.to_numeric(dataframe2['exchange'], errors='coerce')
dataframe2['date']=pd.to_numeric(dataframe2['date'], errors='coerce')

#Display data type and updated table
dataframe2.info()
print(dataframe2)

enter image description here

enter image description here



Read more here: https://stackoverflow.com/questions/66321950/how-can-i-print-a-pandas-table-with-converted-values-in-python

Content Attribution

This content was originally published by NinjaCoder98 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: