我正在尝试按照此处的建议使用 Homebrew 安装 pipenv 。
首先,我跑了$ brew install pipenv。然后, brew install python 3.7 自动,我可以正确使用pipenv。但是,我想在 Python 3.6 上使用 pipenv,所以我跑了$ brew switch python 3.7 3.6.5,然后当我尝试时$ pipenv install出现如下错误:
dyld: Library not loaded: @executable_path/../.Python
Referenced from: /usr/local/Cellar/pipenv/2018.11.26/libexec/bin/python3.7
Reason: image not found
Abort trap: 6
Run Code Online (Sandbox Code Playgroud)
是否有任何解决方案可以将 pipenv 与 Python 3.6.5 一起安装?
谢谢你。
我有一个带有单词和标签的Pandas数据框
words tags
0 I WW
1 am XX
2 newbie YY
3 . ZZ
4 You WW
5 are XX
6 cool YY
7 . ZZ
Run Code Online (Sandbox Code Playgroud)
是否有任何方法如何从数据框创建列表列表,如下所示:
[[('I', 'WW'), ('am', 'XX'), ('newbie', 'YY'), ('.','ZZ')],
[('You', 'WW'), ('are', 'XX'), ('cool', 'YY'), ('.','ZZ')]]
Run Code Online (Sandbox Code Playgroud)
它是元组列表的列表.列表中的每个列表都用('.','ZZ').意思是它是一个句子.
我可以迭代数据帧的每一行并创建列表并在条件为真时附加它,但是有没有"pandas"方法来解决它?
我在 Pandas DataFrame Column 中有一个字典的字符串表示,如下所示:
>>> df['the_column']
0 "{'a': 1., 'b': 2., 'c':3.}"
1 "{'a': 4., 'b': 5., 'c':6.}"
2 "{'a': 7., 'b': 8., 'c': 9.}"
3 "{'a': 10., 'b': 11., 'c':12.}"
...
Run Code Online (Sandbox Code Playgroud)
我想将每个键附加到现有 DataFrame 中的列,这怎么可能?
我试过这样的事情:
list_of_new_col = [json.loads(c) for c in df['the_column']]
# resulting list of dictionary
# convert it to pandas DataFrame
# and then concat with the existing DataFrame
Run Code Online (Sandbox Code Playgroud)
但我得到了
TypeError: the JSON object must be str, bytes or bytearray, not 'float'
关于如何解决这个问题的任何想法?
谢谢你。
注意:我犯了一个错误,请检查已接受的答案和评论以获取详细信息。
python ×3
dataframe ×2
pandas ×2
dictionary ×1
homebrew ×1
list ×1
pipenv ×1
python-3.x ×1
tuples ×1