Comments (4)
Can you share a dummy code example of this behaviour? The below is working fine for me:
import awswrangler as wr
import pandas as pd
df = pd.DataFrame({
"datetime": pd.date_range("2018-01-01", periods=2, freq="h"),
"str": ["a", "b"]
})
print(df)
print(df.dtypes)
df.to_csv("./test_2769.csv", index=False)
path = "s3://bucket/test_2769.py"
wr.s3.to_csv(df, path, index=False)
wr.s3.download(path, "./test_s3_2769.csv")
datetime str
0 2018-01-01 00:00:00 a
1 2018-01-01 01:00:00 b
datetime datetime64[ns]
str object
dtype: object
The downloaded csv file does contain the 00:00:00
datetime,str
2018-01-01 00:00:00,a
2018-01-01 01:00:00,b
from aws-sdk-pandas.
Hi - thank you for your help on this!
This is within a lambda function:
cur.execute("select * from test")
offer_reports = cur.fetchall()
data = pd.DataFrame(test)
if not data.empty:
wr.s3.to_csv(data, f's3://cdc-target/test.csv',index=False)
I tried using df.to_csv()
but getting an write error within the lambda function when trying to use that function.
from aws-sdk-pandas.
Your code feeds a test
variable to pd.DataFrame
but it is referenced nowhere else so hard to infer anything from it. In any case, here are two suggestions:
- Ensure that the column is indeed of type
datetime64
- pandas to_csv has a
date_format
argument that you can leverage to enforce how datetime objects are formatted (e.g.'%d/%m/%Y %H:%M:%S'
)
from aws-sdk-pandas.
Hi @jaidisido - apologies, I was trying to remove any syntax from my code, my code actually is the following:
cur.execute("select * from reports")
reports = cur.fetchall()
data = pd.DataFrame(reports)
if not data.empty:
wr.s3.to_csv(data, f's3://cdc/reports.csv',index=False)
with this code, for some reason it is stripping out 00:00:00, if i add 1 second to it, then I have no issues exporting out datetime.
I tried using to_csv
in the lambda function but running into permission issues and haven't been able to resolve the permission issues yet.
from aws-sdk-pandas.
Related Issues (20)
- Question regarding wr.athena.to_iceberg HOT 4
- Support client-side parameter resolution in wr.athena.create_ctas_table HOT 1
- Cannot write parquet in an S3 path that includes white spaces when using ray HOT 1
- Provide option to skip commit in postgresql.to_sql to allow usage of transactions HOT 1
- Incorrect error message or implementation for datetime formatting? HOT 1
- Unsupported Athena type: json
- Requests for Additional Argument `name_function` on `awswrangler.s3.to_parquet()` HOT 1
- Support IAM Trusted Identity Propagation and Lake Formation with Athena
- Support IAM Trusted Identity Propagation with Redshift
- Upsert column parameters HOT 1
- Get column parameters HOT 2
- s3.read_parquet_table and exception "Unknown parameter in input: "ExcludeColumnSchema", must be one of: CatalogId, DatabaseName, TableName, Expression, NextToken, Segment, MaxResults" HOT 2
- The `to_property_graph` docstring in the Neptune module is not well written and does not describe the behavior of the function when the node already exists HOT 1
- Postgres upsert table creation
- Insight into error `awswrangler.exceptions.QueryFailed: Iceberg cannot access the requested resource` HOT 2
- athena.to_iceberg function is not deleting temp_table_xxxxx properly in Athena HOT 1
- Add s3_output parameter to athena.delete_from_iceberg_table method HOT 1
- wr.s3.download fits the whole file into memory, with 2x memory allocation
- Upsert mode for SQL Server HOT 1
- Lack of `verify` input to customize SSL verify option limits smooth usage of the package modules
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-sdk-pandas.