error when submitting machine learning project I am trying to make a submission of a machine learning classification problem. I have a test dataset where to try my model. To submit I have to build a csv file. The prblem is that when I go building this csv file by doing:

sub = pd.DataFrame({'instructions': test['instructions'],'compiler':new_pred_class}).to_csv('sub.csv')
sub.head()


I get the following error message:

AttributeError                            Traceback (most recent call last)
&lt;ipython-input-37-f223adaf5068&gt; in &lt;module&gt;
  1 sub = pd.DataFrame({'instructions': test['instructions'],'compiler':new_pred_class}).to_csv('sub.csv')
----&gt; 2 sub.head()

AttributeError: 'NoneType' object has no attribute 'head'


Can somebody please help me? Thank's in advance.
The return type of pandas.DataFrame.to_csv is None.

So your first line assigns sub = None: 

sub = pd.DataFrame({'instructions': test['instructions'],'compiler':new_pred_class}).to_csv('sub.csv')


This is probably what you wanted:

sub = pd.DataFrame({'instructions': test['instructions'],'compiler':new_pred_class})
sub.to_csv('sub.csv')
sub.head()