question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: to_clipboard raises an error with null values in data frame

See original GitHub issue

With the latest version of pandas installed on windows, running the following code will raise an error:

df = pd.DataFrame(['\x00'])
df.to_clipboard(index=False, excel=False)

Here is the traceback:

ArgumentError Traceback (most recent call last)

<ipython-input-7-2549db3ae4d0> in <module> 1 df = pd.DataFrame([‘\x00’]) ----> 2 df.to_clipboard(index=False, excel=False)

e:\Anaconda\lib\site-packages\pandas\core\generic.py in to_clipboard(self, excel, sep, **kwargs) 3023 from pandas.io import clipboards 3024 -> 3025 clipboards.to_clipboard(self, excel=excel, sep=sep, **kwargs) 3026 3027 @final

e:\Anaconda\lib\site-packages\pandas\io\clipboards.py in to_clipboard(obj, excel, sep, **kwargs) 143 else: 144 objstr = str(obj) –> 145 clipboard_set(objstr)

e:\Anaconda\lib\site-packages\pandas\io\clipboard_init_.py in lazy_load_stub_copy(text) 631 global copy, paste 632 copy, paste = determine_clipboard() –> 633 return copy(text) 634 635

e:\Anaconda\lib\site-packages\pandas\io\clipboard_init_.py in copy_windows(text) 454 # the object must have been allocated using the 455 # function with the GMEM_MOVEABLE flag. –> 456 count = wcslen(text) + 1 457 handle = safeGlobalAlloc(GMEM_MOVEABLE, count * sizeof(c_wchar)) 458 locked_handle = safeGlobalLock(handle)

e:\Anaconda\lib\site-packages\pandas\io\clipboard_init_.py in call(self, *args) 306 307 def call(self, *args): –> 308 ret = self.f(*args) 309 if not ret and get_errno(): 310 raise PyperclipWindowsException("Error calling " + self.f.name)

ArgumentError: argument 1: <class ‘ValueError’>: embedded null character

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mzeitlin11commented, Sep 6, 2021

Might still be specific to different Windows OSes - see an issue like #38527 which only occurred for WSL 2.0

1reaction
Hossein1399commented, Sep 6, 2021

Hi! I use windows 10 and Python 3.8 and PyCharm professional 2020.3 . My computer uses CPU Intel core I5 9600k and 8G ram. I executed above codes and there wasn’t any error and I could print the data.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Key Error after droping null values in pandas data frame
I have a simple dataframe as :
Read more >
R/data.table.R - Rdrr.io
table.R. In data.table: Extension of `data.frame`. Defines functions .parse_on .prepareFastSubset isReallyReal gforce gsd gvar gmax gmin gmedian ...
Read more >
Passwordstate Changelog
Fixed an issue with the copy to clipboard feature where certain characters where being encoded to a different value; Fixed an error in...
Read more >
Changelog — Python 3.11.1 documentation
gh-99729: Fix an issue that could cause frames to be visible to Python code as they ... of its string representation when raising...
Read more >
Release Notes — Airflow Documentation
Fix some bug in web ui dags list page (auto-refresh & jump search null state) ... Fix the errors raised when None is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found