If you have a csv file with numbers of the form: 8,971 when you import these they will be imported as strings due to the comma. If you then try to plot your dataframe you may find you get an error: ....no numeric data to plot ..... It is possible to work around this problem in a few ways, one involves the thousands parameter to read_csv. This will get rid of the comma but the data may still be strings. You can however use the df.astype('float') command to convert to float type. You can also specify a column to convert - df['column name'],astype('float'). Example code:
0 Comments
Leave a Reply. |
This blog includes:Scripts mainly in Python with a few in R covering NLP, Pandas, Matplotlib and others. See the home page for links to some of the scripts. Also includes some explanations of basic data science terminology. Archives
October 2018
|