title: How can I upload a dataframe as csv to azure by Python?
body: <p>I am working with Python and Pyspark, and I want to upload a CSV file to an azure blob storage. I have already a dataframe generated by code: df. What I want to do is the next:</p>
  
  <pre><code># Dataframe generated by code
  df
  
  # Create the BlockBlockService that is used to call the Blob service for the storage account
  block_blob_service = BlockBlobService(account_name='name', account_key='key') 
  
  container_name ='results-csv'
  
  d = {'one' : pandas.Series([1., 2., 3.], index=['a', 'b', 'c']), 'two' : pandas.Series([1., 2., 3., 4.], index=['a', 'b', 'c', 'd'])}
  df = pandas.DataFrame(d)
  
  
  writer = pandas.ExcelWriter(df, engine='xlsxwriter')
  
  a = df.to_excel(writer, sheet_name='Sheet1', index=False, engine='xlsxwriter')
  
  
  block_blob_service.create_blob_from_stream(container_name, 'test', a)
  </code></pre>
  
  <p>I get the error:</p>
  
  <pre><code>ValueError: stream should not be None.
  </code></pre>
  
  <p>So I want to upload the content of the dataframe as a blob to the storage location provided above. Is there any way to do that without first generating a CSV file in my local computer?  </p>