Last active
February 4, 2024 09:42
-
-
Save nsdevaraj/1f2f4605188c0a4ad4ef5c69d215fa68 to your computer and use it in GitHub Desktop.
raw data css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
from datetime import datetime, timedelta | |
# Read the CSV file | |
df = pd.read_csv('Rawdata.csv') | |
# Define the start and end dates | |
start_date = datetime(2020, 1, 1) | |
end_date = datetime(2024, 12, 31) | |
# Generate a list of dates within the specified range | |
date_array = [start_date + timedelta(days=x) for x in range((end_date - start_date).days + 1)] | |
# Convert the dates to the desired string format ('%d-%m-%Y') | |
date_array_str = [date.strftime('%d-%m-%Y') for date in date_array] | |
# Create a dictionary to store the dataframes for each date | |
ndf = {} | |
frames = [] | |
# Update the 'Date' column with the new dates | |
for each in date_array_str: | |
ndf[each] = df.copy() | |
ndf[each]['Value'] = np.random.randint(500,20000, size=len(df)) | |
ndf[each]['Date'] = each | |
frames.append(ndf[each]) | |
print("for loop df done") | |
# Concatenate the dataframes | |
result = pd.concat(frames) | |
# Save the updated Excel file | |
result.to_csv('Outdata.csv', index=False) | |
# check status with sh | |
#tag=$( tail -n 1 Outdata.csv ) | |
#echo $tag |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment