Tushare returns the dataframe format of panda, but an error occurs when executing the following code: typeerror: empty ‘dataframe’: no numeric data to plot
import tushare as ts
df_all = ts.realtime_boxoffice()
df_box_office = df['BoxOffice']
df_box_office.index = df['Irank']
df_box_office.plot(kind='bar')
Repeatedly output DF [‘boxoffice ‘] to confirm that it has value. I can’t figure out why it will report “empty”, and Baidu has no result
I thought there was a bug in the combination of tusahre and pandas. When I was ready to give up, I saw “numeric” in the error report. Does it mean that DF [‘boxoffice ‘] is a string type, not a numeric type, which leads to the error report
See the usage of “astype ()” in the official documents of panda, and change the code to the following successful drawing (in addition, use “ PD. To_ Numeric ()
“is OK, but I have to go back to panda from tushare. I feel that the code doesn’t look so smooth
import tushare as ts
df_all = ts.realtime_boxoffice()
df_box_office = df['BoxOffice'].astype(float)
df_box_office.index = df['Irank']
df_box_office.plot(kind='bar')
Similar Posts:
- [Solved] Pandas Read CSV Error: TypeError: Empty ‘DataFrame’: no numeric data to plot
- only size-1 arrays can be converted to Python scalars
- [Solved] React Native Error: Module does not exist in the module map
- Office com reports an error. It seems that Microsoft’s test is no more than soso
- Install Office 16 Click to run extensibility component
- [Solved] Pycharm Error: Error: failed to send plot to http://127.0.0.1:63342
- How to Solve Python SyntaxError: EOL while scanning string literal
- Office Visio Install Error: Office 16 Click-to-Run Extensibility Component
- [Solved] Element-ui Error: [Vue warn]: Invalid prop: type check failed for prop “index”. Expected String with value “1”, got Number with value 1
- ERROR: syntax error at end of input & Database Error: invalid input syntax for type numeric: “Not reviewed”