这应该很简单,但是经过几个小时的搜索,我仍然对自己做错的事情感到茫然。
我尝试了使用MultiIndexing.from_和其他多种方法的不同方法,但我做不到这一点。
import pandas as pd
list_of_customers = ['Client1', 'Client2', 'Client3']
stat_index = ['max', 'current', 'min']
list_of_historic_timeframes = ['16:10', '16:20', '16:30']
timeblock = pd.DataFrame(index=([list_of_customers, stat_index]), columns=list_of_historic_timeframes)
timeblock.fillna(0, inplace=True)
print(timeblock)
Run Code Online (Sandbox Code Playgroud) 我有一个包含几列的数据框。后来,添加了标题为“活动”的列。如果“Volume”列包含大于 0 的任何值,我需要将“Active”设置为 1。
这是我如何尝试的一个简单示例:
import pandas as pd
active_df = pd.DataFrame(columns=['Volume'])
active_df['Volume'] = 0, 0, 22, 22, 0, 22, 0, 22, 0, 22
active_df['Active'] = 0
active_df['Active'].loc[active_df['Volume'] > 0] = 1
print(active_df)
Run Code Online (Sandbox Code Playgroud)
尽管这会产生预期的结果,但我不断收到警告:“正在尝试在 DataFrame 切片的副本上设置值”
我已经阅读了参考页面:http : //pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy但仍然无法解决这个问题。
我以为我已经在其他代码中解决了这个问题并解决了它,但是我在现有代码中找不到示例。
import pysolr
solr = pysolr.Solr('http://replaced_url.abc:8983/solr/#/tran_timings_shard1_replica2/query', timeout=10)
results = solr.search('SubmitterId:clientname')
Run Code Online (Sandbox Code Playgroud)
拉取平面文件时,我可以转到 solr Web 界面http://replaced_url.abc:8983/solr/#/tran_timings_shard1_replica2/query并执行 SubmitterId:clientname 的简单查询
我已经搜索了几个小时并尝试通过示例进行操作,但无论我将什么作为 solr.search 查询变量,我始终会收到错误:
从 None json.decoder.JSONDecodeError 引发 JSONDecodeError("期望值", s, err.value):期望值:第 1 行第 1 列(字符 0)