JupytextAI
Using Bing AI to Generate a Data Science Jupyter Notebook¶
Prompt: Create an example of a data science jupyter notebook in py percent format. Use the Palmer Penguins dataset (https://tessarinseve.pythonanywhere.com/staticweb/palmerpenguins.csv).
In [ ]:
In [ ]:
# Import libraries
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
In [ ]:
# Load the dataset from the URL
url = 'https://tessarinseve.pythonanywhere.com/staticweb/palmerpenguins.csv'
df = pd.read_csv(url)
In [ ]:
# Explore the dataset
df.head()
df.info()
df.describe()
In [ ]:
# Plot the distribution of species
sns.countplot(data=df, x='species')
plt.show()
In [ ]:
# Plot the relationship between flipper length and body mass
sns.scatterplot(data=df, x='flipper_length_mm', y='body_mass_g', hue='species')
plt.show()
Copying DataFrames to the Clipboard with pandas¶
The to_clipboard method in pandas can copy a DataFrame to the system clipboard.
In [2]:
import pandas as pd
from sqlite3 import connect
# memory SQLite database connection
conn = connect(':memory:')
url = 'https://tessarinseve.pythonanywhere.com/staticweb/palmerpenguins.csv'
df = pd.read_csv(url)
df.to_sql(name='palmerpenguins', con=conn)
avg = pd.read_sql('SELECT AVG(body_mass_g) as "Average Body Mass" ,species as Species FROM palmerpenguins GROUP BY species ', conn)
print(avg)
avg.to_clipboard()
In [ ]:
In [ ]: