Git Product home page Git Product logo

Comments (8)

martindurant avatar martindurant commented on August 14, 2024

That's a lot of code and stuff I'm not familiar with, it would be really useful to try to pare down the reproducer to the minimum required to show the problem.

At a complete guess columns=column_dict in pd.DataFrame() is passing some non-string items derived from the database stuff. You may need explicit str() around these.

from fastparquet.

TrentGlover avatar TrentGlover commented on August 14, 2024

from fastparquet.

TrentGlover avatar TrentGlover commented on August 14, 2024

same error when attempting to turn all columns into strings...

data_query: str = "Select {} from archive.Ibs.PHOALD WITH (NOLOCK) Where Convert(date, Transaction_time) > Convert("
"date, '2019-05-20') and Convert(date, Transaction_time) <= Convert(date, '2019-06-20') "

...

cursor = conn.cursor()
metadata_sql = 'select top 1 * from archive.Ibs.PHOALD WITH (NOLOCK)'
print(metadata_sql)
cursor.execute(metadata_sql)
column_names = ''
field_names = [i[0] for i in cursor.description]
for j in field_names:
    j = 'convert(nvarchar, ' + j + ') as ' + j
    column_names = column_names + ',' + j
column_names = column_names[1:]
print(f"{column_names}")

sql = data_query.format(column_names)
print(f"{sql}")

from fastparquet.

martindurant avatar martindurant commented on August 14, 2024

A "quoted_name" is entering into your dataframe metadata somewhere, so the task is to find out where. Maybe fastparquet should be converting it to a string internally, but I would bet that requiring a real string is a reasonable expectation in this case.

I'm afraid I don't really know what your code it doing, I don't normally work with DB cursor objects. You might find it easier to use pd.from_sql_query instead, as I suspect it might do the correct conversions for you.

from fastparquet.

TrentGlover avatar TrentGlover commented on August 14, 2024

the problem definitely looks like it is native to the fastparquet code. i've called it without modification and it is still throwing the error.

from fastparquet.

martindurant avatar martindurant commented on August 14, 2024

i've called it without modification and it is still throwing the error.

What did you call exactly? Did you manage to make a dataframe showing this problem without SQL?

from fastparquet.

TrentGlover avatar TrentGlover commented on August 14, 2024

from fastparquet.

martindurant avatar martindurant commented on August 14, 2024

I mean:

     b_df = pd.DataFrame(row_batch, columns=column_dict, dtype=str)
     b_df = b_df.astype(dtype=column_dict)

here both the original columns and the ones supplied in dtype= have keys that came from the SQL driver, and probably responsible for the "quoted_name" in the error. Try converting them to actual str before doing anything with them:

columns = {str(k): v for k, v in columns_dict.items()}

Are the dtypes really all str?

from fastparquet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.