从不耐烦的Core Java中:
...数组列表没有初始化程序语法。最好的办法是构造一个数组列表,如下所示:
ArrayList<String> friends = new ArrayList<>(List.of("Peter", "Paul"));
Run Code Online (Sandbox Code Playgroud)
但是当我尝试编译此代码时遇到错误:
error: cannot find symbol
ArrayList<String> friends = new ArrayList<>(List.of("Peter", "Paul"));
^
symbol: variable List
Run Code Online (Sandbox Code Playgroud)
我的进口是:
import java.util.List;
import java.util.ArrayList;
Run Code Online (Sandbox Code Playgroud)
谢谢
这在批处理文件中有效:
sqlcmd -Q "exec sp_mysp @refdate = '2019-04-29'" -S myserver -d mydb -o C:\myfolder\result.csv
Run Code Online (Sandbox Code Playgroud)
但我希望批处理文件循环遍历日期列表,并将每个列表成员作为变量传递给 -Q,而不是对日期进行硬编码,并且输出文件也应以日期开头。
我尝试过一次约会
set inputdate = '2019-04-29'
set "outputfile=C:\myfolder\%inputdate%_result.csv"
sqlcmd -Q "exec sp_mysp @refdate = try_cast(%inputdate% as date) " -S myserver -d mydb -o outputfile
Run Code Online (Sandbox Code Playgroud)
但出现错误:Incorrect syntax near the keyword 'as'
删除 inputdate 周围的 '%' 会出现错误消息:Incorrect syntax near 'inputdate'
使用 @inputdate 会出现错误:Incorrect syntax near '@inputdate'
我要检查,如果任何dataframe行的列给定数目有任何一组值(不同的套不同的列),并分配boolean相应的-我想我可能需要的组合apply()和any(),但不完全击中它正是:
所以,对于数据帧:
bank_dict = {'Name' : ['A', 'B', 'C', 'D', 'E'],
'Type' : ['Retail', 'Corporate', 'Corporate', 'Wholesale', 'Retail'],
'Overdraft': ['Y', 'Y', 'Y', 'N', 'N'],
'Forex': ['USD', 'GBP', 'EUR', 'JPY', 'GBP']}
Run Code Online (Sandbox Code Playgroud)
有真相清单:
truth_list = [bank_df['Type'].isin(['Retail']), bank_df['Overdraft'].isin(['Yes']), bank_df['Forex'].isin(['USD', 'GBP'])]
Run Code Online (Sandbox Code Playgroud)
结果df应如下所示:
Name Type Overdraft Forex TruthCol
0 A Retail Y USD 1
1 B Corporate Y GBP 1
2 C Corporate Y EUR 1
3 D Wholesale N JPY 0
4 E Retail N GBP …Run Code Online (Sandbox Code Playgroud) 我有一个从列表列表返回列表的函数,其中返回列表按索引号对每个列表的成员进行分组。代码和示例:
def listjoinervar(*lists: list) -> list:
"""returns list of grouped values from each list
keyword arguments:
lists: list of input lists
"""
assert(len(lists) > 0) and (all(len(i) == len(lists[0]) for i in lists))
joinedlist = [None] * len(lists) * len(lists[0])
for i in range(0, len(joinedlist), len(lists)):
for j in range(0, len(lists[0])):
joinedlist[i//len(lists[0]) + j*len(lists[0])] = lists[i//len(lists[0])][j]
return joinedlist
a = ['a', 'b', 'c']
b = [1, 2, 3]
c = [True, False, False]
listjoinervar(a, b, c)
# ['a', 1, True, …Run Code Online (Sandbox Code Playgroud) 尝试运行 JGraphT hello world示例,这里的POM如下所示:
<groupId>org.jgrapht</groupId>
<artifactId>jgrapht-core</artifactId>
<version>1.4.0</version>
Run Code Online (Sandbox Code Playgroud)
但这似乎并没有拉下 org.jgrapht.nio.* ,文件树如下:
我需要在 POM 中做什么才能成功完成这些操作:
import org.jgrapht.nio.*;
import org.jgrapht.nio.dot.DOTExporter;
Run Code Online (Sandbox Code Playgroud)
谢谢
我一直在使用ROMEL托雷斯的alpha_vantage包,但也想从蟒蛇直接使用阿尔法华帝API(提供了更大的功能)与包请求作为这里所描述的卷曲通过Python的API调用:
import requests
import alpha_vantage
API_URL = "https://www.alphavantage.co/query"
data = {
"function": "TIME_SERIES_DAILY",
"symbol": "NIFTY",
"outputsize": "compact",
"datatype": "csv"
"apikey": "XXX",
}
response = requests.get(API_URL, data)
print(response.json())[/code]
Run Code Online (Sandbox Code Playgroud)
但是正在返回的字典中收到以下错误消息:
{“错误消息”:“无效的API调用。请在TIME_SERIES_DAILY之前重试或访问文档(https://www.alphavantage.co/documentation/)。'}
使用requests.post(),结果为:
response = requests.post(API_URL, data)
{'detail': 'Method "POST" not allowed.'}
Run Code Online (Sandbox Code Playgroud)
I've re-checked the documentation and am following all the required API parameters. Appreciate some help re what I might be missing here and what the correct call would be and/or any other alternative approach. Thanks
sql-server 连接器adodbapi是唯一在我的环境中工作的连接器。
import adodbapi
conn = adodbapi.connect("PROVIDER=SQLOLEDB;Data Source={0};Database={1}; \
UID={2};PWD={3};".format(server,db,user,pwd))
cursor = conn.cursor()
query_list = [row for row in cursor]
type(query_list[0]) = adodbapi.apibase.SQLrow
Run Code Online (Sandbox Code Playgroud)
如何将此列表转换为 pandas df?
谢谢
python ×4
java ×2
pandas ×2
adodbapi ×1
alphavantage ×1
api ×1
arraylist ×1
batch-file ×1
jgrapht ×1
sql-server ×1