Example #1
0
from pydataset import data
data('iris')
data('mtcars')

#https://vincentarelbundock.github.io/Rdatasets/datasets.html
import statsmodels.api as sm
mtcars = sm.datasets.get_rdataset(dataname='mtcars', package= 'datasets')
mtcars.data.head()


#%%
#Load from Excel/ CSV and export to
data = mtcars.data
data.head(6)
type(data)
data.to_csv('mtcars.csv')
data.to_excel('mtcarsExcel.xlsx','sheet3', header=False)

#writing to multiple sheets
writer = pd.ExcelWriter('test.xlsx', engine='xlsxwriter')
# Write each dataframe to a different worksheet. you could write different string like above if you want
data.to_excel(writer, sheet_name='sheet1')
data.to_excel(writer, sheet_name='sheet2')
# Close the Pandas Excel writer and output the Excel file.
writer.save()

#%%
data.to_excel?
#load from CSV and Excel
data2a
data2a = pd.read_csv('mtcars.csv') #when csv is in project folder
Example #2
0
# sns.set(style="ticks", color_codes=True)
iris = sns.load_dataset("iris")
sns.pairplot(iris)


#%%
#Load Inbuilt Datasets
import statsmodels.api as sm
#https://vincentarelbundock.github.io/Rdatasets/datasets.html
mtcars = sm.datasets.get_rdataset(dataname='mtcars', package='datasets')
mtcars.data.head()
#%%%
from pydataset import data
mtcars = data('mtcars')
mtcars.head()

#%%
#Load from Excel/ CSV and export to
data = mtcars.data
data.head()

data.to_csv('exportcsv1.csv')
data.to_excel('exportexcel1.xlsx','sheet1', header=False)

#load from CSV and Excel
data2a = pd.read_csv('exportcsv1.csv')
data2a.head()

data2b = pd.read_excel('exportexcel1.xlsx','sheet1')
data2b.head()