text
stringlengths
132
525
<s>[INST] How to load a CSV file in Python using Pandas? [/INST] import pandas as pd\ndf = pd.read_csv('path/to/your/file.csv') </s>
<s>[INST] How to load a CSV file in Python without external libraries? [/INST] with open('path/to/your/file.csv', 'r') as file:\n csv_reader = csv.reader(file)\n for row in csv_reader:\n print(row) </s>
<s>[INST] How to load a CSV file from an S3 bucket in Python using Boto3? [/INST] import boto3\nimport pandas as pd\ns3 = boto3.client('s3')\nobj = s3.get_object(Bucket='your-bucket-name', Key='path/to/your/file.csv')\ndf = pd.read_csv(obj['Body']) </s>
<s>[INST] How to load a CSV file from an S3 bucket in R using aws.s3 package? [/INST] library(aws.s3)\ndf <- s3read_using(FUN=read.csv, object='path/to/your/file.csv', bucket='your-bucket-name') </s>
<s>[INST] How to load a CSV file from a Git repository in Python using Requests? [/INST] import requests\nimport pandas as pd\nurl = 'https://raw.githubusercontent.com/username/repo/branch/path/to/your/file.csv'\nresponse = requests.get(url)\ndf = pd.read_csv(response.content) </s>
<s>[INST] How to load a CSV file from a Git repository in R using httr? [/INST] library(httr)\nurl <- 'https://raw.githubusercontent.com/username/repo/branch/path/to/your/file.csv'\nresponse <- GET(url)\ndf <- read.csv(text=content(response, 'text')) </s>
<s>[INST] How to load a CSV file from Google Cloud Storage in Python using Google Cloud client library? [/INST] from google.cloud import storage\nimport pandas as pd\nclient = storage.Client()\nbucket = client.bucket('your-bucket-name')\nblob = bucket.blob('path/to/your/file.csv')\nurl = blob.generate_signed_url(version='v4', expiration=datetime.timedelta(minutes=15), method='GET')\ndf = pd.read_csv(url) </s>
<s>[INST] How to load a CSV file from Google Cloud Storage in R using googleCloudStorageR? [/INST] library(googleCloudStorageR)\ngcs_get_object('path/to/your/file.csv', bucket = 'your-bucket-name', saveToDisk = 'local_file.csv')\ndf <- read.csv('local_file.csv') </s>
<s>[INST] How to load a CSV file from Azure Blob Storage in Python using Azure Storage Blob client? [/INST] from azure.storage.blob import BlobServiceClient, BlobClient\nimport pandas as pd\nconnect_str = 'your_connection_string'\nblob_service_client = BlobServiceClient.from_connection_string(connect_str)\nblob_client = blob_service_client.get_blob_client(container='your-container-name', blob='path/to/your/file.csv')\ndownload_stream = blob_client.download_blob()\ndf = pd.read_csv(download_stream.content_as_text()) </s>
<s>[INST] How to load a CSV file from Azure Blob Storage in R using AzureStor? [/INST] library(AzureStor)\nend_point <- storage_endpoint('https://youraccount.blob.core.windows.net/', key='yourkey')\ncontainer <- storage_container(end_point, 'your-container-name')\nblob <- storage_download(container, 'path/to/your/file.csv', 'local_file.csv')\ndf <- read.csv('local_file.csv') </s>
<s>[INST] How to load a CSV file in Python, and remove rows with missing values if they are less than 10% of the total rows? [/INST] import pandas as pd\ndf = pd.read_csv('path/to/your/file.csv')\nmissing_percentage = df.isnull().mean().max()\nif missing_percentage < 0.1:\n df = df.dropna() </s>
<s>[INST] How to load a CSV file in Python, check for missing values in specific columns, and remove rows with missing values in these columns if they are less than 10% of the total rows? [/INST] import pandas as pd\ndf = pd.read_csv('path/to/your/file.csv')\ncolumns_to_check = ['column1', 'column2']\nmissing_percentage = df[columns_to_check].isnull().mean().max()\nif missing_percentage < 0.1:\n df = df.dropna(subset=columns_to_check) </s>
<s>[INST] How to load a CSV file in Python, and remove rows where all values are missing if they constitute less than 10% of the total rows? [/INST] import pandas as pd\ndf = pd.read_csv('path/to/your/file.csv')\ntotal_rows = len(df)\nrows_all_missing = df.isnull().all(axis=1).sum()\nif (rows_all_missing / total_rows) < 0.1:\n df = df.dropna(how='all') </s>
<s>[INST] How to load a CSV file in Python using Pandas? [/INST] import pandas as pd\ndf = pd.read_csv('path/to/your/file.csv') </s>
<s>[INST] How to remove duplicate rows from a DataFrame in Python using Pandas? [/INST] import pandas as pd\ndf = pd.read_csv('path/to/your/file.csv')\ndf = df.drop_duplicates() </s>
<s>[INST] How to normalize a column in a DataFrame in Python using Pandas? [/INST] from sklearn.preprocessing import MinMaxScaler\nimport pandas as pd\ndf = pd.read_csv('path/to/your/file.csv')\nscaler = MinMaxScaler()\ndf['normalized_column'] = scaler.fit_transform(df[['column_to_normalize']]) </s>
<s>[INST] How to convert a column to datetime in a DataFrame in Python using Pandas? [/INST] import pandas as pd\ndf = pd.read_csv('path/to/your/file.csv')\ndf['date_column'] = pd.to_datetime(df['date_column']) </s>
<s>[INST] How to extract the month from a datetime column in a DataFrame in Python using Pandas? [/INST] import pandas as pd\ndf = pd.read_csv('path/to/your/file.csv')\ndf['date_column'] = pd.to_datetime(df['date_column'])\ndf['month'] = df['date_column'].dt.month </s>
<s>[INST] How to extract the day from a datetime column in a DataFrame in Python using Pandas? [/INST] import pandas as pd\ndf = pd.read_csv('path/to/your/file.csv')\ndf['date_column'] = pd.to_datetime(df['date_column'])\ndf['day'] = df['date_column'].dt.day </s>
<s>[INST] How to extract the year from a datetime column in a DataFrame in Python using Pandas? [/INST] import pandas as pd\ndf = pd.read_csv('path/to/your/file.csv')\ndf['date_column'] = pd.to_datetime(df['date_column'])\ndf['year'] = df['date_column'].dt.year </s>
<s>[INST] How to extract the day of the week from a datetime column in a DataFrame in Python using Pandas? [/INST] import pandas as pd\ndf = pd.read_csv('path/to/your/file.csv')\ndf['date_column'] = pd.to_datetime(df['date_column'])\ndf['day_of_week'] = df['date_column'].dt.dayofweek </s>
<s>[INST] How to extract the week number from a datetime column in a DataFrame in Python using Pandas? [/INST] import pandas as pd\ndf = pd.read_csv('path/to/your/file.csv')\ndf['date_column'] = pd.to_datetime(df['date_column'])\ndf['week_number'] = df['date_column'].dt.isocalendar().week </s>
<s>[INST] How to extract the quarter from a datetime column in a DataFrame in Python using Pandas? [/INST] import pandas as pd\ndf = pd.read_csv('path/to/your/file.csv')\ndf['date_column'] = pd.to_datetime(df['date_column'])\ndf['quarter'] = df['date_column'].dt.quarter </s>
<s>[INST] How to fill missing values in a DataFrame in Python using Pandas? [/INST] import pandas as pd\ndf = pd.read_csv('path/to/your/file.csv')\ndf = df.fillna(method='ffill') </s>
<s>[INST] How to normalize a specific column in a CSV file using Pandas in Python? [/INST] import pandas as pd\nfrom sklearn.preprocessing import MinMaxScaler\ndf = pd.read_csv('your_file.csv')\nscaler = MinMaxScaler()\ndf['your_column'] = scaler.fit_transform(df[['your_column']]) </s>
<s>[INST] How to convert a column to datetime and extract the year, month, day, and weekday from it using Pandas in Python? [/INST] import pandas as pd\ndf = pd.read_csv('your_file.csv')\ndf['date_column'] = pd.to_datetime(df['date_column'])\ndf['year'] = df['date_column'].dt.year\ndf['month'] = df['date_column'].dt.month\ndf['day'] = df['date_column'].dt.day\ndf['weekday'] = df['date_column'].dt.weekday </s>
<s>[INST] How to drop rows with missing values if they constitute less than 10% of the total rows in a CSV file using Pandas in Python? [/INST] import pandas as pd\ndf = pd.read_csv('your_file.csv')\nmissing_thresh = len(df) * 0.1\nif df.isnull().sum().max() < missing_thresh:\n df = df.dropna() </s>

No dataset card yet

Downloads last month
1