-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Misaligned columns from read_csv on Ecobee CVS #38830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
there's an extra trailing comma in those rows In [147]: len('Date,Time,System Setting,System Mode,Calendar Event,Program Mode,Cool Set Temp (F),Heat Set Temp (F),Current Temp (F),Current Humidity (%RH),Outdoor Temp (F)
...: ,Wind Speed (km/h),Cool Stage 1 (sec),Heat Stage 1 (sec),Fan (sec),DM Offset,Thermostat Temperature (F),Thermostat Humidity (%RH),Study (F),Study2,Breakfast Nook
...: (F),Breakfast Nook2'.split(','))
Out[147]: 22
In [148]: len('2020-12-22,02:55:00,heat,heatOff,,Sleep,85,61,67.4,40,30.8,0,0,0,0,,67.4,40,,,,,'.split(','))
Out[148]: 23 which is why pandas forces the first column (Date values) to become the index - you can see that here in your |
Thanks for that observation! I agree that the file is invalid. Adding |
The docs for So the solution is to specify Pandas' behavior in this scenario is documented in the user guide (https://pandas.pydata.org/pandas-docs/stable/user_guide/io.html#column-and-index-locations-and-names) although the wording
seems to imply that this would only apply in the case where number of elements in the non-header row is greater than the ones in the header row by 1. In [159]: s = '''a,b
...: 1,2,3,4
...: 2,3,4,5'''
In [160]: pd.read_csv(StringIO(s))
Out[160]:
a b
1 2 3 4
2 3 4 5 Looking at this - it fits all the columns to indexes as needed. |
Yep, bad wording here. But the behavior is deliberate. Maybe clarifying the docs? Edit: Currently if we have less columns than data fields with index_col=False the data are ignored. In the future this should raise a Warning |
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
Code Sample, a copy-pastable example
with
pdbug.csv
being this:(a slight edit of a CSV file of HVAC system performance data downloaded from https://ecobee.com)
gives
Problem description
Observe that the "Date" column absorbs both the date and time values provided, and that the "Time" column returend by read_csv contains data intended for the next column over ("System Setting"). The source CSV seems sane, but the
read_csv
output does not.Output of
pd.show_versions()
pandas : 1.2.0
numpy : 1.19.4
pytz : 2020.4
dateutil : 2.8.1
pip : 20.3.1
setuptools : 44.0.0
Cython : 0.29.21
pytest : 6.2.0
hypothesis : None
sphinx : 3.3.1
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : None
pandas_datareader: None
bs4 : 4.9.3
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: