Home > Blockchain >  Is there a way to download a sample CSV file
Is there a way to download a sample CSV file

Time:10-20

I used a sample of a csv program to do some tables on Jupiter notebook, I now need to download that sample csv file so I can look at it in excel, is there a way I can download the sample

I need to download lf if possible.

Here is my code:

warnings.filterwarnings("ignore")

import numpy as np
import pandas as pd
import io
import requests 

df = pd.read_csv("diamonds.csv")

lf = df.sample(5000, random_state=999)

import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline 
%config InlineBackend.figure_format = 'retina'
plt.style.use("seaborn")

lf.sample(5000, random_state=999)'''

CodePudding user response:

Answer from here:

import urllib.request
urllib.request.urlretrieve("http://jupyter.com/diamond.csv", "diamond.csv")

CodePudding user response:

You first need to convert the sample to a dataframe and then you can export it.

dframe.to_csv(“file_name.csv”)

Let me know if it works.

  • Related